1 /* 2 * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef _HARDWARE_VREG_H 8 #define _HARDWARE_VREG_H 9 10 #include "pico.h" 11 12 #if PICO_RP2040 13 #include "hardware/structs/vreg_and_chip_reset.h" 14 #else 15 #include "hardware/structs/powman.h" 16 #endif 17 18 #ifdef __cplusplus 19 extern "C" { 20 #endif 21 22 /** \file vreg.h 23 * \defgroup hardware_vreg hardware_vreg 24 * 25 * \brief Voltage Regulation API 26 * 27 */ 28 29 /** Possible voltage values that can be applied to the regulator 30 */ 31 enum vreg_voltage { 32 #if !PICO_RP2040 33 VREG_VOLTAGE_0_55 = 0b00000, 34 VREG_VOLTAGE_0_60 = 0b00001, 35 VREG_VOLTAGE_0_65 = 0b00010, 36 VREG_VOLTAGE_0_70 = 0b00011, 37 VREG_VOLTAGE_0_75 = 0b00100, 38 VREG_VOLTAGE_0_80 = 0b00101, 39 #endif 40 VREG_VOLTAGE_0_85 = 0b00110, ///< 0.85 V 41 VREG_VOLTAGE_0_90 = 0b00111, ///< 0.90 V 42 VREG_VOLTAGE_0_95 = 0b01000, ///< 0.95 V 43 VREG_VOLTAGE_1_00 = 0b01001, ///< 1.00 V 44 VREG_VOLTAGE_1_05 = 0b01010, ///< 1.05 V 45 VREG_VOLTAGE_1_10 = 0b01011, ///< 1.10 V 46 VREG_VOLTAGE_1_15 = 0b01100, ///< 1.15 V 47 VREG_VOLTAGE_1_20 = 0b01101, ///< 1.20 V 48 VREG_VOLTAGE_1_25 = 0b01110, ///< 1.25 V 49 VREG_VOLTAGE_1_30 = 0b01111, ///< 1.30 V 50 #if !PICO_RP2040 51 // Above this point you will need to set POWMAN_VREG_CTRL_DISABLE_VOLTAGE_LIMIT 52 VREG_VOLTAGE_1_35 = 0b10000, 53 VREG_VOLTAGE_1_40 = 0b10001, 54 VREG_VOLTAGE_1_50 = 0b10010, 55 VREG_VOLTAGE_1_60 = 0b10011, 56 VREG_VOLTAGE_1_65 = 0b10100, 57 VREG_VOLTAGE_1_70 = 0b10101, 58 VREG_VOLTAGE_1_80 = 0b10110, 59 VREG_VOLTAGE_1_90 = 0b10111, 60 VREG_VOLTAGE_2_00 = 0b11000, 61 VREG_VOLTAGE_2_35 = 0b11001, 62 VREG_VOLTAGE_2_50 = 0b11010, 63 VREG_VOLTAGE_2_65 = 0b11011, 64 VREG_VOLTAGE_2_80 = 0b11100, 65 VREG_VOLTAGE_3_00 = 0b11101, 66 VREG_VOLTAGE_3_15 = 0b11110, 67 VREG_VOLTAGE_3_30 = 0b11111, 68 #endif 69 70 // Note the "max" here assumes that VREG_CTRL_DISABLE_VOLTAGE_LIMIT is not set 71 VREG_VOLTAGE_MIN = VREG_VOLTAGE_0_85, ///< Always the minimum possible voltage 72 VREG_VOLTAGE_DEFAULT = VREG_VOLTAGE_1_10, ///< Default voltage on power up. 73 VREG_VOLTAGE_MAX = VREG_VOLTAGE_1_30, ///< Always the maximum possible voltage 74 }; 75 76 77 /*! \brief Set voltage 78 * \ingroup hardware_vreg 79 * 80 * \param voltage The voltage (from enumeration \ref vreg_voltage) to apply to the voltage regulator 81 **/ 82 void vreg_set_voltage(enum vreg_voltage voltage); 83 84 85 /*! \brief Enable use of voltages beyond the safe range of operation 86 * \ingroup hardware_vreg 87 * 88 * This allows voltages beyond VREG_VOLTAGE_MAX to be used, on platforms where 89 * they are available (e.g. RP2350). Attempting to set a higher voltage 90 * without first calling this function will result in a voltage of 91 * VREG_VOLTAGE_MAX. 92 **/ 93 void vreg_disable_voltage_limit(void); 94 95 #ifdef __cplusplus 96 } 97 #endif 98 99 #endif 100