1 // Copyright 2018 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #pragma once
6 
7 #include "aml-pwm.h"
8 #include <fbl/unique_ptr.h>
9 #include <zircon/device/thermal.h>
10 
11 namespace thermal {
12 // This class represents a voltage regulator
13 // on the Amlogic board which provides interface
14 // to set and get current voltage for the CPU.
15 class AmlVoltageRegulator {
16 
17 public:
18     DISALLOW_COPY_AND_ASSIGN_ALLOW_MOVE(AmlVoltageRegulator);
AmlVoltageRegulator()19     AmlVoltageRegulator(){};
20     zx_status_t Init(zx_device_t* parent, opp_info_t* opp_info);
21     uint32_t GetVoltage();
22     zx_status_t SetVoltage(uint32_t microvolt);
23 
24 private:
25     fbl::unique_ptr<thermal::AmlPwm> pwm_;
26     opp_info_t opp_info_;
27     int current_voltage_index_;
28 };
29 } // namespace thermal
30