/** * @file * @brief Registers, Bit Masks and Bit Positions for the PMU module. */ /* **************************************************************************** * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * Except as contained in this notice, the name of Maxim Integrated * Products, Inc. shall not be used except as stated in the Maxim Integrated * Products, Inc. Branding Policy. * * The mere transfer of this software does not imply any licenses * of trade secrets, proprietary technology, copyrights, patents, * trademarks, maskwork rights, or any other form of intellectual * property whatsoever. Maxim Integrated Products, Inc. retains all * ownership rights. * * $Date: 2016-10-10 19:24:21 -0500 (Mon, 10 Oct 2016) $ * $Revision: 24667 $ * **************************************************************************** */ /* Define to prevent redundant inclusion */ #ifndef _PMU_H_ #define _PMU_H_ /* **** Includes **** */ #include "pmu_regs.h" #ifdef __cplusplus extern "C" { #endif /** * @ingroup periphlibs * @defgroup pmuGroup Peripheral Management Unit * @brief Peripheral Management Unit (PMU) Interface. * @{ */ /** * Enum type for the clock scale used for the PMU timeout clock. */ typedef enum { PMU_PS_SEL_DISABLE = MXC_V_PMU_CFG_PS_SEL_DISABLE, /**< Timeout disabled */ PMU_PS_SEL_DIV_2_8 = MXC_V_PMU_CFG_PS_SEL_DIV_2_8, /**< Timeout clk = PMU clock / 2^8 = 256 */ PMU_PS_SEL_DIV_2_16 = MXC_V_PMU_CFG_PS_SEL_DIV_2_16, /**< Timeout clk = PMU clock / 2^16 = 65536 */ PMU_PS_SEL_DIV_2_24 = MXC_V_PMU_CFG_PS_SEL_DIV_2_24 /**< Timeout clk = PMU clock / 2^24 = 16777216 */ }pmu_ps_sel_t; /** * Enumeration type for the number of clk ticks for the timeout duration. */ typedef enum { PMU_TO_SEL_TICKS_4 = MXC_V_PMU_CFG_TO_SEL_TICKS_4, /**< timeout = 4 * Timeout clk period */ PMU_TO_SEL_TICKS_8 = MXC_V_PMU_CFG_TO_SEL_TICKS_8, /**< timeout = 8 * Timeout clk period */ PMU_TO_SEL_TICKS_16 = MXC_V_PMU_CFG_TO_SEL_TICKS_16, /**< timeout = 16 * Timeout clk period */ PMU_TO_SEL_TICKS_32 = MXC_V_PMU_CFG_TO_SEL_TICKS_32, /**< timeout = 32 * Timeout clk period */ PMU_TO_SEL_TICKS_64 = MXC_V_PMU_CFG_TO_SEL_TICKS_64, /**< timeout = 64 * Timeout clk period */ PMU_TO_SEL_TICKS_128 = MXC_V_PMU_CFG_TO_SEL_TICKS_128, /**< timeout = 128 * Timeout clk period */ PMU_TO_SEL_TICKS_256 = MXC_V_PMU_CFG_TO_SEL_TICKS_256, /**< timeout = 256 * Timeout clk period */ PMU_TO_SEL_TICKS_512 = MXC_V_PMU_CFG_TO_SEL_TICKS_512 /**< timeout = 512 * Timeout clk period */ }pmu_to_sel_t; /* * The macros like the one below are designed to help build static PMU programs * as arrays of 32bit words. */ #define PMU_IS(interrupt, stop) ((!!interrupt) << PMU_INT_POS) | ((!!stop) << PMU_STOP_POS) /* * Structure type to build a PMU Move Op Code. */ typedef struct pmu_move_des_t { uint32_t op_code : 3; /* 0x0 */ uint32_t interrupt : 1; uint32_t stop : 1; uint32_t read_size : 2; uint32_t read_inc : 1; uint32_t write_size : 2; uint32_t write_inc : 1; uint32_t cont : 1; uint32_t length : 20; uint32_t write_address; uint32_t read_address; } pmu_move_des_t; #define PMU_MOVE(i, s, rs, ri, ws, wi, c, length, wa, ra) \ (PMU_MOVE_OP | PMU_IS(i,s) | ((rs & 3) << PMU_MOVE_READS_POS) | ((!!ri) << PMU_MOVE_READI_POS) | \ ((ws & 3) << PMU_MOVE_WRITES_POS) | ((!!wi) << PMU_MOVE_WRITEI_POS) | ((!!c) << PMU_MOVE_CONT_POS) | ((length & 0xFFFFF) << PMU_MOVE_LEN_POS)), wa, ra /* new_value = value | (old_value & ~ mask) */ typedef struct pmu_write_des_t { uint32_t op_code : 3; /* 0x1 */ uint32_t interrupt : 1; uint32_t stop : 1; uint32_t : 3; uint32_t write_method : 4; uint32_t : 20; uint32_t write_address; uint32_t value; uint32_t mask; } pmu_write_des_t; #define PMU_WRITE(i, s, wm, a, v, m) (PMU_WRITE_OP | PMU_IS(i,s) | ((wm & 0xF) << PMU_WRITE_METHOD_POS)), a, v, m typedef struct pmu_wait_des_t { uint32_t op_code : 3; /* 0x2 */ uint32_t interrupt : 1; uint32_t stop : 1; uint32_t wait : 1; uint32_t sel : 1; uint32_t : 25; uint32_t mask1; uint32_t mask2; uint32_t wait_count; } pmu_wait_des_t; #define PMU_WAIT(i, s, sel, m1, m2, cnt) (PMU_WAIT_OP | PMU_IS(i,s) | ((cnt>0)?(1<