/* * * pal_sysPsc.h * Description: * see below * * * Copyright (C) 2008, Texas Instruments, Incorporated * * This program is free software; you can distribute it and/or modify it * under the terms of the GNU General Public License (Version 2) as * published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. * */ /** \file pal_sysPsc.h \brief Power and Sleep Controller header file \author Mansoor Ahamed (mansoor.ahamed@ti.com) \version 0.1 */ #ifndef __PAL_SYS_PSC_H__ #define __PAL_SYS_PSC_H__ #include #include /* Following are the flag used to determine domain/module state */ #define PSC_FLAG_ALWAYS_ON 0x00000001 #define PSC_FLAG_MEM_SLWKP 0x00000002 #define PSC_FLAG_PROXYGEM 0x00000004 #define PSC_FLAG_ICEPICK 0x00000008 #define PSC_FLAG_BLK_RST 0x00000010 #define PSC_FLAG_EPC_PENDING 0x00000020 #define PSC_FLAG_ERROR 0x00000040 /* Some important bit fields used by PSC */ #define PAL_SYS_PSC_CCM 0x00000002 #define PAL_SYS_PSC_OVERRIDE 0x00000001 /** \struct PAL_SYS_PSC_DOMINFO_T \brief This structure holds the domain information */ typedef struct PAL_SYS_PSC_DOMINFO_tag { PAL_SYS_POWER_CTRL_T state; /**< This field provides the domain state (on or off) */ unsigned int flags; /**< This flag provides following information 'Always On' domain or not (PSC_FLAG_ALWAYS_ON), If error flag set (PSC_FLAG_ERROR), Is this a Memory Sleep/Wake domain (PSC_FLAG_MEM_SLWKP), Is this a Proxy GEM domain (PSC_FLAG_PROXYGEM), Does it have Ice Pick support (PSC_FLAG_ICEPICK) Block all Reset except POR (PSC_FLAG_BLK_RST), External Power Control Pending (PSC_FLAG_EPC_PENDING) */ unsigned int pdstat; /**< Power Domain Status register contents */ }PAL_SYS_PSC_DOMINFO_T; /** \struct PAL_SYS_PSC_MODINFO_T \brief This structure holds the domain information */ typedef struct PAL_SYS_PSC_MODINFO_tag { int domain; /**< which power domain this module belongs to */ PAL_SYS_POWER_CTRL_T state; /**< current module state Disable -reset deasserted and clock gated, Enable -reset deasserted and clock running, SwRstDisable -reset asserted and clock gated SyncReset -reset asserted and clock running */ int numclk; /**< No of mod clocks supported on LPSC (1 - 4) */ unsigned int flags; /**< This flag provides following information If error flag set (PSC_FLAG_ERROR) Soft reset blocked (PSC_FLAG_BLK_RST) */ unsigned int mdstat; /**< Module status register contents */ }PAL_SYS_PSC_MODINFO_T; /** \enum PAL_SYS_PSC_REGISTER_T \brief This structure holds the domain information */ typedef enum PAL_SYS_PSC_REGISTER_tag { PAL_SYS_PSC_MERRCR=0, /**< module error pending register */ PAL_SYS_PSC_PERRCR, /**< power error pending register */ PAL_SYS_PSC_EPCCR, /**< External power control clear register */ }PAL_SYS_PSC_REGISTER_T; /** \struct PAL_SYS_PSC_REGMAP_T \brief This structure holds the psc register memory map information */ typedef struct PAL_SYS_PSC_REGMAP_tag { volatile const unsigned int pid; /**< Peripheral ID Register */ volatile unsigned int reserved0[3]; /* -------Reserved 0x004 to 0x00F */ volatile unsigned int gblctl; /**< Global Control Register */ volatile unsigned int gblstat; /**< Global Status Register */ volatile unsigned int inteval; /**< Interrupt Evaluation Register */ volatile unsigned int reserved1[9]; /* -------Reserved 0x01F to 0x03F */ volatile unsigned int merrpr[4]; /**< Array of Module Error Pending Registers, each register can hold 32 modules */ volatile unsigned int merrcr[4]; /**< Array of Module Error Clear Registers, each register can hold 32 modules */ volatile unsigned int perrpr[2]; /**< Power Error Pending Register */ volatile unsigned int perrcr[2]; /**< Power Error Clear Register */ volatile unsigned int epcpr[2]; /**< External Power Control Pending Register */ volatile unsigned int epccr[2]; /**< External Power Control Clear Register */ volatile unsigned int reserved2[32]; /* --------Reserve 0x07f to 0x100 */ volatile unsigned int railstat; /**< Power Rail Status Register */ volatile unsigned int railctl; /**< Power Rail Counter Control Register */ volatile unsigned int railsel; /**< Power Rail Counter Select */ volatile unsigned int railctl_1[5]; /**< Power Rail Counter Control Register */ volatile unsigned int ptcmd[2]; /**< Power Transition Command Register */ volatile unsigned int ptstat[2]; /**< Power Domain Transition Status Register */ volatile unsigned int reserved3[52]; /* --------Reserve 0x12f to 0x200 */ volatile unsigned int pdstat[64]; /**< Power Domain Status Register (one register for each domain) */ volatile unsigned int pdctl[64]; /**< Power Domain Control Register (one register for each domain) */ volatile unsigned int pdcfg[64]; /**< Power Domain Configuration Register (one register for each domain) */ volatile unsigned int reserved4[64]; /* --------Reserve 0x5ff to 0x400 */ volatile const unsigned int mdcfg[128];/**< Module Configuration Register (one register for each module) */ volatile unsigned int mdstat[128]; /**< Module Status Register (one register for each module) */ volatile unsigned int mdctl[128]; /**< Module Control Register (one register for each module) */ /* why to waste memory */ /* volatile unsigned int reserved5[256]; */ /* --------Reserve 0xFFF to 0xC00 */ }PAL_SYS_PSC_REGMAP_T; /*! \fn PAL_Result PAL_sysGetDomainInfo(PAL_SYS_PSC_DOMAIN_T domain_id, PAL_SYS_PSC_DOMINFO_T *info) \brief This API is used to retrieve the current status of the domain. \param domain_id Unique domain id whose information has to be retrieved. \param info This structure holds the following domain information, domain state (on or off), always on or not, error info, domain status reg content, memory sleep/wake info, Proxy GEM, IcePick support, External Power Control Pending state . \return Returns 0 on success else returns a negative value */ PAL_Result PAL_sysGetDomainInfo(PAL_SYS_PSC_DOMAIN_T domain_id, PAL_SYS_PSC_DOMINFO_T *info); /*! \fn PAL_Result PAL_sysPscGetModuleInfo(PAL_SYS_PSC_MODULE_T module_id, PAL_SYS_PSC_MODINFO_T *info) \brief This API is used to retrieve the current status of the module. \param module_id Unique module id whose information has to be retrieved. \param info This structure holds the following module information, power domain information, present module state (Disable -reset deasserted and clock gated, Enable -reset deasserted and clock running, SwRstDisable -reset asserted and clock gated SyncReset -reset asserted and clock running), error info, module status reg contents, No of mod clocks supported on LPSC (1 - 4), soft reset blocked or not . \return Returns 0 on success else returns a negative value */ PAL_Result PAL_sysPscGetModuleInfo(PAL_SYS_PSC_MODULE_T module_id, PAL_SYS_PSC_MODINFO_T *info); /*! \fn PAL_Result PAL_sysPscSetDomainState(PAL_SYS_PSC_DOMAIN_T domain_id, PAL_SYS_POWER_CTRL_T mode) \brief This API is used to switch on or off a power domain. \param domain_id Unique domain id whose state has to be changed. \param mode New mode (POWER_CTRL_POWER_UP, POWER_CTRL_POWER_DOWN) \return Returns 0 on success else returns a negative value */ PAL_Result PAL_sysPscSetDomainState(PAL_SYS_PSC_DOMAIN_T domain_id, PAL_SYS_POWER_CTRL_T mode); /*! \fn PAL_Result PAL_sysPscSetModuleState(PAL_SYS_PSC_MODULE_T module_id, PAL_SYS_POWER_CTRL_T mode) \brief This API is used to change the state of a module. \param domain_id Unique module id whose state has to be changed. \param mode New momde (POWER_CTRL_PSC_ENABLE, POWER_CTRL_PSC_DISABLE, POWER_CTRL_PSC_SW_RST_DISABLE, POWER_CTRL_PSC_SYNC_RESET) \return Returns 0 on success else returns a negative value */ PAL_Result PAL_sysPscSetModuleState(PAL_SYS_PSC_MODULE_T module_id, PAL_SYS_POWER_CTRL_T mode); /*! \fn PAL_Result PAL_sysPscClearRegister(PAL_SYS_PSC_DOMAIN_T domain_id, PAL_SYS_PSC_MODULE_T modudle_id, PAL_SYS_PSC_REGISTER_T reg) \brief This API is used to clear error status (power or module) or EPC pending status for a domain/module. The params domain_id/module_id is used based on the register selected. \param domain_id Unique domain id whose status has to be cleared \param module_id Unique module id whose status has to be cleared \param reg Which register has to be cleared module error pending register (PAL_SYS_PSC_MERRCR), power error pending register (PAL_SYS_PSC_PERRCR), External power control clear register (PAL_SYS_PSC_EPCCR), \return Returns 0 on success else returns a negative value */ PAL_Result PAL_sysPscClearRegister(PAL_SYS_PSC_DOMAIN_T domain_id, PAL_SYS_PSC_MODULE_T module_id, PAL_SYS_PSC_REGISTER_T reg); /*! \fn PAL_Result PAL_sysPscInit() \brief This API is used to Initilize the PSC to default known values. Also, it checks if the PSC is hardwired for bypass mode \param psc_base Virtual base address of PSC module \param ccm_controlled A value of one programs the psc such that the states can only be changed by CCM \param pid Contents of Peripheral id register \return Returns 0 on success and negative value on error; */ PAL_Result PAL_sysPscInit(unsigned int psc_base, int ccm_controlled, unsigned int *pid); /*! \fn PAL_Result PAL_sysPscSetMdctl(PAL_SYS_PSC_MODULE_T module_id, unsigned int value, unsigned char preserve_state) \brief This API is used to load the specified value to module control register \param module_id Unique module id whose state has to be changed. \param value New value to load to MDCTL (Refer PSC spec for MDCTL register bit details) \param preserve_state A value of "1" requests the API to update all fields except state field and a value of "0" loads the new state also. \return Returns 0 on success else returns a negative value */ PAL_Result PAL_sysPscSetMdctl(PAL_SYS_PSC_MODULE_T module_id, unsigned int value, unsigned char preserve_state); #if 0 /* TODO: These are optional and of low priority and will be implemented later */ PAL_sysPscSetPowerRail(); PAL_sysPscGetPowerRail(); PAL_sysPscRegisterCallback(); PAL_sysPscISR() 1. if EPC (External Power Controller support) a. call callback - callback should use getdomaininfo() ans see which domain needs EPC service,based on direction (on / off) switch on or off EPC and wait for it to settle down and then return b. set MDCTL.EPCGOOD = 0 or 1 based on direction c. write 1 to EPCCR 2. if error, clear and notify respective callback #endif #endif /* __PAL_SYS_PSC_H__ */