~aleteoryx/muditaos

ref: d8fc8f9f90a46ff1f0ec9ff0ca278db6dab8987a muditaos/module-bsp/bsp/lpm/bsp_lpm.hpp -rw-r--r-- 1.8 KiB
d8fc8f9f — Kuba [EGD-7909] Fix Retry mode change on fail 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <optional>
#include <memory>
#include <bsp/common.hpp>

namespace bsp
{

    class LowPowerMode
    {
      public:
        enum class OscillatorSource
        {
            External,
            Internal
        };
        enum class RebootType
        {
            NormalRestart,
            GoToUpdaterUpdate,       //! Goto updater into the update mode
            GoToUpdaterFactoryReset, //! GOto updater into the factory reset mode
            GoToUpdaterRecovery      //! Goto to updater into recovery mode
        };

        LowPowerMode()          = default;
        virtual ~LowPowerMode() = default;

        static std::optional<std::unique_ptr<LowPowerMode>> Create();

        virtual int32_t PowerOff()                = 0;
        virtual int32_t Reboot(RebootType reason) = 0;

        virtual void SetCpuFrequency(CpuFrequencyHz freq) = 0;
        virtual void SetHighestCoreVoltage() = 0;
        [[nodiscard]] CpuFrequencyHz GetCurrentFrequencyLevel() const noexcept;
        [[nodiscard]] virtual uint32_t GetCpuFrequency() const noexcept = 0;

        virtual void SwitchOscillatorSource(OscillatorSource source) = 0;
        virtual void SetBootSuccess()                                = 0;

        virtual void EnableDcdcPowerSaveMode()  = 0;
        virtual void DisableDcdcPowerSaveMode() = 0;

        virtual void DisconnectInternalLoadResistor()  = 0;
        virtual void ConnectInternalLoadResistor() = 0;

        virtual void SwitchToRegularModeLDO()  = 0;
        virtual void SwitchToLowPowerModeLDO() = 0;

      protected:
        CpuFrequencyHz currentFrequency = CpuFrequencyHz::Level_6;
    };
} // namespace bsp