/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* $Source: src/usr/lpc/lpcdd.H $ */ /* */ /* OpenPOWER HostBoot Project */ /* */ /* Contributors Listed Below - COPYRIGHT 2014,2019 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ /* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ /* you may not use this file except in compliance with the License. */ /* You may obtain a copy of the License at */ /* */ /* http://www.apache.org/licenses/LICENSE-2.0 */ /* */ /* Unless required by applicable law or agreed to in writing, software */ /* distributed under the License is distributed on an "AS IS" BASIS, */ /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ /* implied. See the License for the specific language governing */ /* permissions and limitations under the License. */ /* */ /* IBM_PROLOG_END_TAG */ #ifndef __LPC_LPCDD_H #define __LPC_LPCDD_H #include #include #include #include #include typedef uint64_t LPCBase_t; /** @file lpcdd.H * @brief Provides the interfaces to the LPC Device Driver */ /** * @brief LPC Device Driver Class * Provides access to the LPC bus for a specific Processor */ class LpcDD { public: /** * @brief Performs a LPC Read Operation * * @param i_trans LPC transaction type * @param i_address LPC address * @param o_buffer Buffer to read data into * @param io_buflen Input: Number of bytes to read, * Output: Number of bytes actually read * * @return Error from operation */ errlHndl_t readLPC(LPC::TransType i_type, uint32_t i_address, void* o_buffer, size_t& io_buflen); /** * @brief Performs a LPC Write Operation * * @param i_trans LPC transaction type * @param i_address LPC address * @param i_buffer Buffer to write data from * @param io_buflen Input: Number of bytes to write, * Output: Number of bytes actually written * * @return Error from operation */ errlHndl_t writeLPC(LPC::TransType i_type, uint32_t i_address, const void* i_buffer, size_t& io_buflen); /** * @brief Check For Errors in OPB and LPCHC Status Registers * * @return Error log if error found */ errlHndl_t checkForLpcErrors(); /** * @brief Enums for different levels of resetting PNOR communication levels */ enum ResetLevels { RESET_CLEAR = 0x00000000, /**< Clear Reset Level */ RESET_OPB_LPCHC_SOFT = 0x00000001, /**< OPB LPCHC Clear Errors */ RESET_OPB_LPCHC_HARD = 0x00000002, /**< OPB LPCHC Reset Logic */ RESET_INIT = 0x00000004, /**< Initial HW setup */ }; /** * @brief Reset hardware to get into clean state * * @parm i_resetLevel How much LPC logic to reset * * @return errlHndl_t NULL on success, else error log */ errlHndl_t hwReset( ResetLevels i_resetLevel ); /** * @brief Get the target associated with this dd instance * * @return Pointer to target */ TARGETING::Target* getProc( void ) { return iv_proc; }; /** * @brief Get the base address of the LPC space * * @return Pointer to base address */ uint64_t getLPCBaseAddr(void) { return iv_lpcBaseAddr; }; /** * @brief Set the base address of the LPC space * * @return Void */ void setLPCBaseAddr(uint64_t * i_baseLPCAddr) { iv_lpcBaseAddr = reinterpret_cast(i_baseLPCAddr); }; /** * @brief Get the start offset in the LPC space * * @return Offset to LPC start address */ uint64_t getLPCStartAddr(void) { return LPC_ADDR_START; }; /** * @brief Block/unblock all LPC operations * @param[in] i_block true: block ops, false: allow ops */ void lock( bool i_block ) { if( i_block ) { mutex_lock(ivp_mutex); } else { mutex_unlock(ivp_mutex); } }; /** * @brief Constructor * @param[in] Processor target associated with the LPC Master */ LpcDD( TARGETING::Target* i_proc = TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL ); /** * @brief Destructor */ ~LpcDD(); protected: /** * @brief Some general constants * */ enum { /** Start of LPC Addr within the memory mapped space*/ LPC_ADDR_START = 0xC0000000, /** Size that LPC takes up (0xC0000000 to 0xFFFFFFFF)*/ LPC_SPACE_SIZE = 0x40000000, /**< OPB LPCM Sync FIR Reg WOX_AND - used to clear the FIR */ OPB_LPCM_FIR_WOX_AND_REG = 0x01010C01, /**< OPB LPCM Sync FIR Mask Reg WO_OR - used to set the mask */ OPB_LPCM_FIR_MASK_WO_OR_REG = 0x01010C05, // LPCHC reset-related registers OPB_MASTER_LS_CONTROL_REG = 0x008, /**