This repository has been archived on 2025-06-06. You can view files and clone it, but cannot push or open issues or pull requests.
Files
android-g900/Start_WM/test6/inc/GFRmIx.h
2010-10-16 00:02:07 +06:00

655 lines
23 KiB
C
Executable File

/* Copyright (c) 2006 NVIDIA Corporation. All rights reserved.
*
* NVIDIA Corporation and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto. Any use, reproduction, disclosure or
* distribution of this software and related documentation without an
* express license agreement from NVIDIA Corporation is strictly prohibited.
*/
/** @file GFRmIx.h
Chip Initialization API header file.
*/
#ifndef __GFRMIX_H__
#define __GFRMIX_H__
#include "GFRm.h"
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
/** @addtogroup groupRmIx Chip Initialization API
*/
/*@{*/
/* GPIO configurations
* Host GPIO1~GPIO7 correspond to HGP0~HGP6, C32KHZ.
* When configured as output, it is necessay to select output as data or
* Clocks or interrupt.
* GFIX_GPIO_CFG_OUTPUT can Or with GFIX_GPIO_CFG_OUTPUT_SEL_*
*/
/* Host GPIO type enum */
typedef enum
{
GFIX_GPIO0 = 0,
GFIX_GPIO1,
GFIX_GPIO2,
GFIX_GPIO3,
GFIX_GPIO4,
GFIX_GPIO5,
GFIX_GPIO6,
GFIX_GPIO7
} GFIX_GPIO_TYPE;
/* Host GPIO operations. */
#define GFIX_GPIO_GET_INPUT_ENABLE 0x80000000UL
#define GFIX_GPIO_GET_OUT_PUT_ENABLE 0x40000000UL
#define GFIX_GPIO_SET_DATA 0x20000000UL
#define GFIX_GPIO_CLR_DATA 0x10000000UL
#define GFIX_GPIO_GET_DATA 0x08000000UL
#define GFIX_GPIO_SET_INPUT_ENABLE 0x04000000UL
#define GFIX_GPIO_CLR_INPUT_ENABLE 0x02000000UL
#define GFIX_GPIO_SET_OUTPUT_ENABLE 0x01000000UL
#define GFIX_GPIO_CLR_OUTPUT_ENABLE 0x00800000UL
/*
* GPIO output select data, configure the pin as data output.
* Meaningful for pin0~pin4(HGP0~HGP4)
*/
#define GFIX_GPIO_CFG_OUTPUT_SEL_DATA 0x00000000
/*
* GPIO output select interrupt, configure the pin as interrupt output.
* Meaningful for pin3(HGP3) only
*/
#define GFIX_GPIO_CFG_OUTPUT_SEL_INTR 0x00000040
/*
* GPIO output select RDY signal
* Meaningful for pin4(HGP4) only
*/
#define GFIX_GPIO_CFG_OUTPUT_SEL_RDY 0x00000100
/*
* For pin5 and pin6(HGP5, HGP6), config output clock or data on HGP5 and HGP6.
*
*/
#define GFIX_GPIO_CFG_OUTPUT_SEL_HGP56_CLK 0x00000800
#define GFIX_GPIO_CFG_OUTPUT_SEL_HGP56_DATA 0x00000000
/*
* For pin5(HGP5)
* select monitor clock to HGP5
*/
#define GFIX_GPIO_CFG_OUTPUT_SEL_HGP5_PLL1 0x00000000
#define GFIX_GPIO_CFG_OUTPUT_SEL_HGP5_PLL2 0x00001000
#define GFIX_GPIO_CFG_OUTPUT_SEL_HGP5_PLLCOSC 0x00002000
#define GFIX_GPIO_CFG_OUTPUT_SEL_HGP5_PLLROSC 0x00003000
/*
* For pin6(HGP6)
* select monitor clock to HGP6
*/
#define GFIX_GPIO_CFG_OUTPUT_SEL_HGP6_PLL2 0x00000000
#define GFIX_GPIO_CFG_OUTPUT_SEL_HGP6_DCFCLK 0x00004000
#define GFIX_GPIO_CFG_OUTPUT_SEL_HGP6_MCCLK 0x00008000
#define GFIX_GPIO_CFG_OUTPUT_SEL_HGP6_DSPCLK 0x0000C000
/*
* For pin7(C32KHZ)
*/
#define GFIX_GPIO_CFG_OUTPUT_SEL_C32KHZ 0x00000000
/*
* Definition of attribute ids for Set/GetAttributes()
*/
typedef enum _GFIX_ATTR_TYPE
{
GFIX_ATTR_NONE = 0,
GFIX_ATTR_DEVICE_INFO,
GFIX_ATTR_DEVICE_INFO_STRUCT, /* Get Device ID & Rev */
GFIX_ATTR_EFUSE_PRODUCT_SKU_ID,
GFIX_ATTR_DRAM_SELF_REFRESH,
GFIX_ATTR_DRAM_DEEP_POWER_DOWN
} GFIX_ATTR_TYPE;
/*
* Definition of module frequency types.
*/
typedef enum _GFIX_MODULEFREQ_TYPE
{
GFIX_MODULEFREQ_OPTIMAL = 0,
GFIX_MODULEFREQ_MINIMUM,
GFIX_MODULEFREQ_MAXIMUM,
GFIX_MODULEFREQ_REQUESTED,
GFIX_MODULEFREQ_ACTUAL
} GFIX_MODULEFREQ_TYPE;
/*
* Definition of module operations.
*/
#define GFIX_DISABLECLOCK 0x00000001
#define GFIX_ENABLECLOCK 0x00000002
#define GFIX_SPECIAL 0x00000004
#define GFIX_FORCEDISABLECLOCK 0x00000008
#define GFIX_FORCEENABLECLOCK 0x00000010
#define GFIX_DYNAMICSWITCH 0x00000020
#define GFIX_FORCEDISABLEMODULE 0x00010000
#define GFIX_FORCEENABLEMODULE 0x00020000
/*
* Clock selections, profile and options
*/
enum
{
#define GFRM_CLOCK(x, y) GFIX_##x,
#define GFRM_CLOCK_PLL(x, y) GFIX_##x,
#include "gfrm_clock_ids.h"
#undef GFRM_CLOCK
#undef GFRM_CLOCK_PLL
GFNUMOFCLOCKIDS
};
enum
{
#define GFRM_CLOCK(x, y) (1 << GFIX_##x )|
#define GFRM_CLOCK_PLL(x, y) (1 << GFIX_##x )|
GFIX_ALL_CLOCKS =
#include "gfrm_clock_ids.h"
0, // | 0 to GFIX_ALL_CLOCKS
#undef GFRM_CLOCK
#undef GFRM_CLOCK_PLL
#define GFRM_CLOCK(x, y) (1 << GFIX_##x )|
#define GFRM_CLOCK_PLL(x, y)
GFIX_NO_PLLS =
#include "gfrm_clock_ids.h"
0, // | 0 to GFIX_NO_PLLS
#undef GFRM_CLOCK
#undef GFRM_CLOCK_PLL
#define GFRM_CLOCK(x, y)
#define GFRM_CLOCK_PLL(x, y) (1 << GFIX_##x )|
GFIX_ONLY_PLLS =
#include "gfrm_clock_ids.h"
0, // | 0 to GFIX_NO_PLLS
#undef GFRM_CLOCK
#undef GFRM_CLOCK_PLL
GFIX_N_CLOCKSOURCES = GFNUMOFCLOCKIDS,
GFIX_NO_CLOCK = 0xFFFFFFFF,
GFIX_PLL_QUERY = 0x80000000
};
#define GFIX_POWER 0x00010000
#define GFIX_PERFORMANCE 0x00020000
#define GFIX_DEFAULTSLK 0x00000000
#define GFIX_HIGHESTSLK 0x00000001
/** Module clock profile */
typedef struct _GFIXMODULECONFIG
{
NvU8 clockSelection; /**< Selection mode */
NvU32 minFrequency; /**< Lowest frequency allowed */
NvU32 optimalFrequency; /**< Optimal frequency */
NvU32 maxFrequency; /**< Max frequency */
NvU32 sourceClocks; /**< Bitfield of valid source clocks */
} GFIXMODULECONFIG, *PGFIXMODULECONFIG;
/** Module state */
typedef struct _GFIXMODULESTATE
{
NvU32 clkRefCount; /**< Reference counter used in GFRmIxEnableModuleClock */
NvU32 clkSelect; /**< Clock selected for module (only valid when clkRefCount is non-zero) */
/**< If clkSelect==GFIX_NO_CLOCK no clock is selected by this module */
NvU32 enableRefCount; /**< Reference counter used in GFRmIxEnableModule */
} GFIXMODULESTATE, *PGFIXMODULESTATE;
/** typedef for callback when the module is disabled */
typedef GF_RETTYPE (*GF_FUNC_RMIX_CALLBACK)(void *handle);
/** Initializes the chip
@param RmHandle (#GFRmHandle) Handle specific to the GFRm
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
GFRmIxInit() is the first function which touches the hardware, there are no
hardware accesses before GFRmIxInit(). It initializes some module's clocks
and as well as taking some modules out of reset. It also initializes
device-control registers.
@see GFRmIxDeInit()
*/
GF_RETTYPE
GFRmIxInit( GFRmHandle RmHandle );
/** De-initializes the chip
@param RmHandle (#GFRmHandle) Handle specific to the GFRm
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
GFRmIxDeInit() does the reverse of GFRmIxInit(), it shut downs the chip.
All modules are put back in reset and clocks turned off.
@see GFRmIxInit()
*/
GF_RETTYPE
GFRmIxDeInit( GFRmHandle RmHandle );
/** This function enables a module's clock
@param RmHandle (#GFRmHandle) Handle specific to the GFRm
@param modid (#eGFModuleIDs) ID of the module
@param option (NvU32) Bit field of options, GFIX_ENABLECLOCK,
GFIX_DISABLECLOCK, GFIX_FORCEENABLECLOCK,
GFIX_FORCEDISABLECLOCK, GFIX_DYNAMICSWITCH, GFIX_SPECIAL
@param special (NvU32) Specifies a module specific setting, only used when
option contains GFIX_SPECIAL
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
This function enables and disables a module's clock as well as enables the
module's source clock. There are two types of enables, the normal enable
and the force enable. When doing a normal enable the module's clock enable
reference count is increased as well as a call to GFRmIxEnableClockSource()
which ensures the module's source clock is enabled. When doing a force
enable/disable the modules reference counter is not touched,
GFRmIxEnableClockSource() is called which increases/deceases the source's
reference count. If the operation is to enable and the clock is currently
disabled, for the both normal enable and force disable GFRmIxEnableModuleClock
will attempt to find the best clock source and divider for the module.
Some modules support a dynamic clock divider, that is the clock doesn't have
to be turned off before reprogramming the divider. To switch a module's
frequency that supports dynamic dividers without first turning the module
off set option to GFIX_DYNAMICSWITCH. GFRmIxEnableModuleClock will attempt
to find the closest frequency to the desired without changing clock sources.
Some modules have special clock configurations such as VI, GFIX_SPECIAL can
be specified along with GFIX_ENABLECLOCK or by itself to configure the special
option for the module.
*/
GF_RETTYPE
GFRmIxEnableModuleClock( GFRmHandle RmHandle,
eGFModuleIDs modid,
NvU32 option,
NvU32 special );
/** Same as GFRmIxEnableModuleClock, but takes a callback
function which will be called when the refcount goes
to zero.
@param func Callback funtion of type GFRmIxEnableModuleClock
@param arg used as an argument to when callback function is called.
@see GFRmIxEnableModuleClock()
*/
GF_RETTYPE
GFRmIxEnableModuleClockEx( GFRmHandle RmHandle,
eGFModuleIDs modid,
NvU32 option,
NvU32 special,
GF_FUNC_RMIX_CALLBACK func,
void *arg);
/** Enables a module
@param RmHandle (#GFRmHandle) Handle specific to the GFRm
@param modid (#eGFModuleIDs) ID of the module
@param option (NvU32) If option is nonzero the module will be enabled
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
This function takes a module out of reset. Each module has a reference
count which is used to keep track of how many outstanding enables the
module has. The module will not be disabled until the reference counter
is returned to zero.
*/
GF_RETTYPE
GFRmIxEnableModule( GFRmHandle RmHandle,
eGFModuleIDs modid,
NvU32 option );
/** Same as GFRmIxEnableModule() but calls the passing in callback
function when the refcount of the module goes to zero.
@param callback Callback function of type GF_FUNC_RMIX_CALLBACK
@param arg Argument passed to the callback function.
@see GFRmIxEnableModule()
*/
GF_RETTYPE
GFRmIxEnableModuleEx( GFRmHandle RmHandle,
eGFModuleIDs modid,
NvU32 option,
GF_FUNC_RMIX_CALLBACK callback,
void *arg
);
/** Changes frequency of a clock.
@param RmHandle (#GFRmHandle) Handle specific to the GFRm
@param option (NvU32) GFIX_PLL1, GFIX_PLL2, GFIX_ROSC, GFIX_OSC,
GFIX_REFCLK0, GFIX_REFCLK1 or GFIX_PLL_QUERY
@param pFrequency (NvU32*) Pointer to 32-bit value in KHz to get three
digit MHz precision. Returns with newly set
current frequency.
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
@retval #GF_ERROR_BAD_PARAMETER Bad parameter passed
This function sets a clock to a certain frequency. If the clock cannot meet
the requested frequency then the closest one will be chosen. For the PLLs
this function determines the closest dividers to arrive at the requested
frequency. To determine the frequency that will be chosen without actually
setting it GFIX_PLL_QUERY can be Or'ed along with the clock ID.
Some clocks only have one frequency that never changes; this function must
still be called at least once to allow the internal logic to know what the
frequency of the clock is. To disable the selection of a clock by a module,
a clock can be disabled by setting its frequency to zero; this will remove
it from consideration for all modules.
This function will fail if a module is already using the clock.
@see GFRmIxGetFrequency()
*/
GF_RETTYPE
GFRmIxSetFrequency( GFRmHandle RmHandle,
NvU32 option,
NvU32 *pFrequency );
/** Retrieves frequency of a clock.
@param RmHandle (#GFRmHandle) Handle specific to the GFRm
@param option (NvU32) GFIX_PLL1, GFIX_PLL2, GFIX_ROSC, GFIX_OSC,
GFIX_REFCLK0, GFIX_REFCLK1
@param pFrequency (NvU32*) Pointer to 32-bit value in KHz to get three
digit MHz precision. Returns with currently
set frequency.
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
@retval #GF_ERROR_BAD_PARAMETER Bad parameter passed
@see GFRmIxSetFrequency()
*/
GF_RETTYPE
GFRmIxGetFrequency( GFRmHandle RmHandle,
NvU32 option,
NvU32 *pFrequency );
/** Sets the requested frequency of the module.
@param RmHandle (#GFRmHandle) Handle specific to the GFRm
@param modid (#eGFModuleIDs) ID of the module
@param frequency (NvU32) 32-bit value in KHz to get three digit MHz
precision
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
This function sets the requested frequency of a module, this value must
lie between the minimum and maximum frequencies specified in
GFRmIxSetModuleConfig(). This value is cached and used when
GFRmIxEnableModuleClock() is called attempting to enable the clock to the
module.
@see GFRmIxSetModuleConfig()
*/
GF_RETTYPE
GFRmIxSetModuleFrequency( GFRmHandle RmHandle,
eGFModuleIDs modid,
NvU32 frequency );
/** This function is used to retrieve clock frequency information about a module.
@param RmHandle (#GFRmHandle) Handle specific to the GFRm
@param modid (#eGFModuleIDs) ID of the module
@param type (#GFIX_MODULEFREQ_TYPE) Type of frequency
@param pFrequency (NvU32*) Pointer to 32-bit value in KHz to get three digit
MHz precision. Returns with currently frequency.
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
*/
GF_RETTYPE
GFRmIxGetModuleFrequency( GFRmHandle RmHandle,
eGFModuleIDs modid,
GFIX_MODULEFREQ_TYPE type,
NvU32 *pFrequency );
/** This function enables and disables power plane(s).
@param RmHandle (#GFRmHandle) Handle specific to the GFRm
@param ppID (NvU32) ID of power plane (More then one can be Or'ed to perform
operation in parallel)
@param operation (#GFIX_POWERPLANE_OP_TYPE) Operation to perform on the
power planes
@param states (NvU32*) Ptr to 32 bit value to store the resulting bit
field of a GFIX_POWERPLANE_OP_QUERY operation.
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
@retval #GF_ERROR_BAD_PARAMETER Bad parameter passed
This function enables and disables power plane(s), multiple power planes can
be disabled in one function call. There is two versions of this functions
specified with the compilation flag GF_EXTERNAL_POWERPLANE_LOGIC. If this
flag is set to 1 then all the power plane logic is done in the platform code,
if 0 then all the logic is done in Ix.
When internal power plane logic is chosen, each power plane has a reference
count. If the power plane is to be enabled or disabled, GFRmIxPowerPlane()
will call out to RmPowerPlane(), which will perform platform specific enabling.
*/
GF_RETTYPE
GFRmIxPowerPlane( GFRmHandle RmHandle,
NvU32 ppID,
GFIX_POWERPLANE_OP_TYPE operation,
NvU32 *states );
/** Enable and disables clock sources.
@param RmHandle (#GFRmHandle) Handle specific to the GFRm
@param clockid (NvU32) ID of the clock
@param state (NvU32) 0 for disable, 1 for enable
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
This function enables and disables a clock's source. A reference counter is
used to ensure the clock's source won't be disabled until there is a matching
number of enable and disable operations. If a clocks source is to be enabled
or disabled, GFRmIxEnableClockSource() will call out to RmEnableClockSource()
to do the platform specific enabling or disabling.
*/
GF_RETTYPE
GFRmIxEnableClockSource( GFRmHandle RmHandle,
NvU32 clockid,
NvU32 state );
/** This function sets the list of reference clocks that a PLL may choose.
@param RmHandle (#GFRmHandle) Handle specific to the GFRm
@param option (NvU32) GFIX_PLL1, GFIX_PLL2
@param clocks (NvU32) Bitfield of clocks. (1<<GFIX_OSC), (1<<GFIX_ROSC),
(1<<GFIX_REFCLK0), (1<<GFIX_REFCLK1)
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
*/
GF_RETTYPE
GFRmIxSetPLLReferenceClocks( GFRmHandle RmHandle,
NvU32 option,
NvU32 clocks );
/** This function sets the bounds and clocking profile of the modules.
@param RmHandle (#GFRmHandle) Handle specific to the GFRm
@param modid (NvU32) ID of the module
@param pConfig (#GFIXMODULECONFIG*) Pointer to module configuration
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
While this function may be called while the module's clock is enabled,
it will not affect the current clock settings of the module but all new
Ix calls dealing with the module will follow the configuration set by
this function.
@see GFRmIxGetModuleConfig()
*/
GF_RETTYPE
GFRmIxSetModuleConfig( GFRmHandle RmHandle,
eGFModuleIDs modid,
GFIXMODULECONFIG *pConfig );
/** This function retrieves the module's configuration
@param RmHandle (#GFRmHandle) Handle specific to the GFRm
@param modid (NvU32) ID of the module
@param pConfig (#GFIXMODULECONFIG*) Pointer to module configuration
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
@see GFRmIxSetModuleConfig()
*/
GF_RETTYPE
GFRmIxGetModuleConfig( GFRmHandle RmHandle,
eGFModuleIDs modid,
GFIXMODULECONFIG *pConfig );
/** This function can perform a master clock enable and disable.
@param RmHandle (#GFRmHandle) Handle specific to the GFRm
@param option (NvU32) 0 for master disable
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
When doing a master disable all module's clocks currently enabled are
disabled. To restore the system to its previous state a master enable
should be performed.
@see GFRmIxEnableModuleClock()
*/
GF_RETTYPE
GFRmIxEnableClock( GFRmHandle RmHandle,
NvU32 option );
/** This function is used to query information about a module's state.
@param RmHandle (#GFRmHandle) Handle specific to the GFRm
@param modid (#eGFModuleIDs) ID of the module
@param pState (#GFIXMODULESTATE*) Pointer to GFIXMODULESTATE structure to
be filled in
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
*/
GF_RETTYPE
GFRmIxGetModuleState( GFRmHandle RmHandle,
eGFModuleIDs modid,
GFIXMODULESTATE *pState );
/** This function forces the selection of a certain clock by a module.
@param RmHandle (#GFRmHandle) Handle specific to the GFRm
@param modid (#eGFModuleIDs) ID of the module
@param clockid (#NvU32) ID of the clock
The clock most be a valid clock for the module (the list of valid clocks
for a module are set using GFRmIxSetModuleConfig()). This function most
be called before the module's clock is enabled or the function call will
fail.
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
@see GFRmIxSetModuleConfig()
*/
GF_RETTYPE
GFRmIxSelectModuleClock( GFRmHandle RmHandle,
eGFModuleIDs modid,
NvU32 clockid );
/** This function sets the PAD calibration register for various modules.
@param RmHandle (#GFRmHandle) Handle specific to the GFRm
@param padType (#NvU32) Type of PAD to modify
@param value (#NvU32) Value to write to PAD register
ctrlType is one of: 0=VI, 1=Host 2=MEM 3=LCD 4=SD 5=Audio
@retval #GF_SUCCESS Success
@retval #GF_ERROR Invalid ctrlType
*/
GF_RETTYPE
GFRmIxSetPADCal( GFRmHandle RmHandle,
NvU32 padType,
NvU32 value);
/** This function sets the PAD control register for various modules.
@param RmHandle (#GFRmHandle) Handle specific to the GFRm
@param padType (#NvU32) Type of PAD to modify
@param value (#NvU32) Value to write to PAD register
ctrlType is one of: 0=VI, 1=Host 2=EMC 3=LCD 4=SD 5=Audio
@retval #GF_SUCCESS Success
@retval #GF_ERROR Invalid ctrlType
*/
GF_RETTYPE
GFRmIxSetPADCtrl( GFRmHandle RmHandle,
NvU32 padType,
NvU32 value);
GF_RETTYPE
GFRmIxGPIO( GFRmHandle RmHandle,
GFIX_GPIO_TYPE gpio,
NvU32 operation,
PGFGPIOSTATUS pGPIOStatus);
GF_RETTYPE
GFRmIxGetProperty( GFRmHandle RmHandle,
PGFPROPERTY pProp );
GF_RETTYPE
GFRmIxSetAttribute( GFRmHandle RmHandle,
GFIX_ATTR_TYPE attrType,
NvU32 attrData );
GF_RETTYPE
GFRmIxGetAttribute( GFRmHandle RmHandle,
GFIX_ATTR_TYPE attrType,
NvU32 *pAttrData );
/*@}*/
#ifdef __cplusplus
}
#endif
#endif // _GFIX_H_