/* * 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. */ #ifndef NVBOARD_H #define NVBOARD_H #include "nvcommon.h" #include "nverror.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** NvBoard - Board Support Package NvBoard is designed to decouple customer platform specifics from generic binary only drivers. The interface must be thread-safe. */ typedef struct NvBoardAperture_t { /* Physical Address */ NvPhysAddr address; /* Size of Aperture */ NvU32 size; } NvBoardAperture; typedef struct NvBoardApertureIO_t { void ( *Write8 )( void *pAddress, NvU8 data ); void ( *Write16 )( void *pAddress, NvU16 data ); void ( *Write32 )( void *pAddress, NvU32 data ); void ( *Write64 )( void *pAddress, NvU64 data ); NvU8 ( *Read8 )( void *pAddress ); NvU16 ( *Read16 )( void *pAddress ); NvU32 ( *Read32 )( void *pAddress ); NvU64 ( *Read64 )( void *pAddress ); } NvBoardApertureIO; typedef struct NvBoardApertures_t { NvBoardAperture hostInterface; /* pIO is null unless the apertures cannot be dereferenced */ NvBoardApertureIO *pIO; } NvBoardApertures; typedef enum { /* Bus type A */ NvBoardBusType_A, /* Bus type C */ NvBoardBusType_C, NvBoardBusType_Forceword = 0x7fffffff, } NvBoardBusType; typedef enum { /* Direct Addressing */ NvBoardBusAddressing_Direct, /* Indirect Addressing */ NvBoardBusAddressing_Indirect, NvBoardBusAddressing_Forceword = 0x7fffffff, } NvBoardBusAddressing; typedef enum { /* 16-bit bus */ NvBoardBusWidth_16, /* 32-bit bus */ NvBoardBusWidth_32, NvBoardBusWidth_Forceword = 0x7fffffff, } NvBoardBusWidth; typedef enum { /* Handshake mode. */ NvBoardBusMode_Handshake, /* Fixed cycle mode. */ NvBoardBusMode_FixedCycle, NvBoardBusMode_Forceword = 0x7fffffff, } NvBoardBusMode; typedef enum { /* Asynchronous. */ NvBoardBusSynchronization_Asynchronous, /* Synchronous. */ NvBoardBusSynchronization_Synchronous, NvBoardBusSynchronization_Forceword = 0x7fffffff, } NvBoardBusSynchronization; typedef enum { /* Active low. */ NvBoardBusReadyPolarity_ActiveLow, /* Active high. */ NvBoardBusReadyPolarity_ActiveHigh, NvBoardBusReadyPolarity_Forceword = 0x7fffffff, } NvBoardBusReadyPolarity; typedef struct NvBoardMode_t { NvBoardBusAddressing GPUaddressing; // Bus perspective from GPU NvBoardBusWidth GPUwidth; NvBoardBusAddressing CPUaddressing; // Bus perspective from CPU NvBoardBusWidth CPUwidth; NvBoardBusType type; NvBoardBusMode mode; NvBoardBusSynchronization synchronization; NvBoardBusReadyPolarity readyPolarity; } NvBoardMode; /** Stateless methods. Methods can be called before NvBoardInit */ /** NvBoardListSupportedModes - Method to enumerate the modes of the board Two calls should be made to this method. On the first call, the method populates the number of modes, for the display. When this call is issued pMode should be NULL. On the second call, the length of the pMode array is indicated by the value of *pNum. When pNum is less than the number of modes the method populates the pMode array with only the first pNum modes. When is more than the number of modes, the method populates the pMode array with the number of modes and writes the number of modes into pNum. The first mode enumerated by this method is the recommended / default mode for the display. @param pNum unsigned integer value indicating the number of modes in the array pMode. @param pMode pointer to an array of mode structures, where the size of the array is determined by the value in pNum. @retval NvSuccess - on success NvErrorBadParameter - when at least one parameter is incorrect */ NvError NvBoardListSupportedModes( NvU32 *pNum, NvBoardMode *pMode ); /** Library Initialization */ /** NvBoardInit - platform initialization. Typically chip select is configured here. NvBoardInit uses a reference counter. The first invocation performs the initialization, all future calls increment the counter. The counter is decremented by NvBoardDeInit. This method is to be called before any other NvBoard methods can be used. @param pMode pointer to structure containing a mode to set on the board. If mode is null, the recommended mode will be chosen. */ NvError NvBoardInit( const NvBoardMode *pMode ); /** NvBoardDeInit - platform deinitialization. */ void NvBoardDeInit( void ); /** Wince platform resume control */ NvError NvBoardResume( void ); /** Wince platform suspend control */ NvError NvBoardSuspend( void ); /** SD card detect status when card detect pin is connected to CPU GPIO pin */ NvError nvBoardSDCardDetectStatus(NvU32 *bCardInserted); /** SD card detect sysintr number if card detect pin is connected to CPU GPIO pin*/ NvError nvBoardSDCardDetectSysintr(NvU32 *dwSysintr); /** SD card socket power pin configuration In general, this pin is connected to CPU GPIO pin, and we need to configure GPIO input/output mode and setup default value */ NvError nvBoardSDSocketPowerInit(void); /** SD card socket power control*/ NvError nvBoardSDSocketPowerOnOff(NvU32 SDPowerOn); /** Camera(VI) interface power plane control*/ NvError nvBoardVIPowerOnOff(NvU32 VIPowerOn); /** OEM specific powerOn related calls after NV backlight ON. @retval ERROR_SUCCESS on success or appropriate wince error codes. */ NvError nvBoard_PostOEMBacklightOn(void); /** OEM specific powerOff related calls after NV backlight Off. @retval ERROR_SUCCESS on success or appropriate wince error codes. */ NvError nvBoard_PostOEMBacklightOff(void); /** NvBoardGetApertures - get apertures */ NvError NvBoardGetApertures( NvBoardApertures *pApertures ); /** NvBoardGetMode - get current mode */ NvError NvBoardGetMode( NvBoardMode *pMode ); /** Device Events -- Abstraction for interrupts */ /* NvDeviceEvent enumerates the types of events. NvBoard implementors should not hardcode event names. The only enumerated value that should be used in the implementation of NvBoard is NvDeviceEvent_Num. */ typedef enum NvDeviceEvent_t { /* NOTE: Currently using unabstracted events until INTx is removed. */ NvDeviceEvent_HOST = 0, NvDeviceEvent_GRMPD, NvDeviceEvent_ME, NvDeviceEvent_JPEGE, NvDeviceEvent_VI, NvDeviceEvent_EPP, NvDeviceEvent_ISP, NvDeviceEvent_DSP, NvDeviceEvent_GR2D, NvDeviceEvent_GR3D, NvDeviceEvent_DISPLAY, NvDeviceEvent_I2S, NvDeviceEvent_IC, NvDeviceEvent_SD, NvDeviceEvent_MC, NvDeviceEvent_EMC, /* NUM should always be the 2nd last enumerated value */ NvDeviceEvent_Num, NvDeviceEvent_Forceword = 0x7fffffff, } NvDeviceEvent; /** NvBoardEnableEvent - Method to enable an event If the event is fired before a client is waiting, the event will be remembered for the next NvBoardWaitForEvent invocation. */ NvError NvBoardEnableEvent( NvDeviceEvent event ); /** NvBoardDisableEvent - Method to disable an event */ void NvBoardDisableEvent( NvDeviceEvent event ); /** NvBoardWaitForEvent - This method blocks until the event is fired Each event may only have one client waiting on it. If more than one client needs to be notified of an event, a broadcast layer will need to be developed on top of this API. Once an event is fired, it is disabled. To reenable the event use NvBoardEnableEvent. */ NvError NvBoardWaitForEvent( NvDeviceEvent event ); /** NvBoardWaitForEventWithTimeOut - NvBoardWaitForEvent with a timeout @param timeOut Unit is milliseconds */ NvError NvBoardWaitForEventWithTimeOut( NvDeviceEvent event, NvU32 timeOut ); /** I2C I/O */ /** NvBoardI2CWrite - I2C write operation. Implementing this function is optional. */ NvError NvBoardI2CWrite( NvU32 addr, const void *ptr, NvU32 size ); /** NvBoardI2CRead - I2C read operation. Implementing this function is optional. */ NvError NvBoardI2CRead( NvU32 addr, void *ptr, NvU32 size ); /** Voltage and power control */ typedef enum NvBoardPowerPlane_t { NvBoardPowerPlane_AOCVDD = 0, NvBoardPowerPlane_VECVDD, NvBoardPowerPlane_MMCVDD, NvBoardPowerPlane_TDCVDD, NvBoardPowerPlane_VVDD, NvBoardPowerPlane_EMVDD, NvBoardPowerPlane_ACVDD, NvBoardPowerPlane_LVDD, NvBoardPowerPlane_HVDD, NvBoardPowerPlane_AUXVDD, NvBoardPowerPlane_R1CVDD, NvBoardPowerPlane_SDVDD, NvBoardPowerPlane_DRAM, NvBoardPowerPlane_Forceword = 0x7fffffff, } NvBoardPowerPlane; typedef enum NvBoardClock_t { NvBoardClock_PLL1 = 0, NvBoardClock_PLL2, NvBoardClock_COSC, NvBoardClock_ROSC, NvBoardClock_REF1, NvBoardClock_REF2, NvBoardClock_Forceword = 0x7fffffff, } NvBoardClock; /** NvBoardSetVoltage - change voltage of hardware block @param voltage Unit is millivolts */ NvError NvBoardSetVoltage( NvBoardPowerPlane block, NvU32 voltage ); /** NvBoardGetVoltage - get voltage of hardware block @param voltage Unit is millivolts */ NvError NvBoardGetVoltage( NvBoardPowerPlane plane, NvU32 *voltage ); /** NvBoardPowerOn - enable power to block */ NvError NvBoardPowerOn( NvBoardPowerPlane plane ); /** NvBoardPowerOff - disable power to block */ NvError NvBoardPowerOff( NvBoardPowerPlane plane ); /** NvBoardClockOn - enable clock */ NvError NvBoardClockOn( NvBoardClock clock ); /** NvBoardClockOff - disable clock */ NvError NvBoardClockOff( NvBoardClock clock ); /** NvBoardSetFrequency - set frequency of clock @param frequency unit is KHz */ NvError NvBoardSetFrequency( NvBoardClock clock, NvU32 frequency ); /** Platfrom specific debug function. This like an ioctl to the platfrom sepcific code. */ void NvBoardDebug(void *p, NvU32 op, NvU32 arg); /** Event notification */ typedef enum { NvBoardDeviceType_Silicon, NvBoardDeviceType_Emulator, NvBoardDeviceType_Forceword = 0x7fffffff, } NvBoardDeviceType; typedef struct NvBoardDeviceInfo_t { NvU32 MinorRev; NvU32 MajorRev; NvU32 ChipID; NvU32 Family; NvBoardDeviceType Type; } NvBoardDeviceInfo; /** NvBoardPostChipInit - Called after the chip is intialized. Chip specific timings can be programmed at this point. NvIrqPostChipInit should be called here. */ NvError NvBoardPostChipInit( NvBoardDeviceInfo *deviceInfo ); /** NvBoardPreChipDeInit - Called before chip is shutdown. NvIrqPreChipDeInit should be called here. */ NvError NvBoardPreChipDeInit( void ); /** NvBoardClockSwitch - Clock switch handling @param frequency Unit is kHz */ NvError NvBoardClockSwitch( NvU32 frequency ); typedef enum NvBoardStateEvent_t { #ifdef NV_WINDOWS_CE NvBoardStateEvent_PreDeviceInit, NvBoardStateEvent_PostDeviceInit, NvBoardStateEvent_PrePanelInit, NvBoardStateEvent_PostPanelInit, NvBoardStateEvent_PreSetMode, NvBoardStateEvent_PostSetMode, NvBoardStateEvent_PreDisplayInit, NvBoardStateEvent_PostDisplayInit, NvBoardStateEvent_PreOEMPowerHandlerVideoPowerOff, NvBoardStateEvent_PostOEMPowerHandlerVideoPowerOff, NvBoardStateEvent_PreOEMPowerHandlerVideoPowerOn, NvBoardStateEvent_PostOEMPowerHandlerVideoPowerOn, #endif NvBoardStateEvent_Forceword = 0x7fffffff, } NvBoardStateEvent; /** NvBoardGlobalStateNotification - Called during global state transitions Only used on Windows CE at the moment. */ NvError NvBoardGlobalStateNotification( NvBoardStateEvent event ); void NvBoardOsWaitUS( NvU32 usec ); void NvBoardOsSleepMS( NvU32 msec ); typedef struct NvBoardOsMutex_t *NvBoardOsMutex; typedef struct NvBoardOsSemaphore_t *NvBoardOsSemaphore; typedef struct NvBoardOsThread_t *NvBoardOsThread; NvError NvBoardOsMutexCreate( const char *key, NvBoardOsMutex *mutex ); void NvBoardOsMutexLock( NvBoardOsMutex mutex ); void NvBoardOsMutexUnlock( NvBoardOsMutex mutex ); void NvBoardOsMutexDestroy( NvBoardOsMutex mutex ); typedef struct NvBoardOsSharedMemDescriptor_t *NvBoardOsSharedMemDescriptor; NvError NvBoardOsSharedMemAlloc( const char *key, size_t size, NvBoardOsSharedMemDescriptor *descriptor ); NvError NvBoardOsSharedMemMap( NvBoardOsSharedMemDescriptor descriptor, size_t offset, size_t size, void **ptr ); void NvBoardOsSharedMemUnmap( void *ptr, size_t size ); void NvBoardOsSharedMemFree( NvBoardOsSharedMemDescriptor descriptor ); void NvBoardOsMemset( void *s, NvU8 c, size_t size ); int NvBoardOsMemcmp( const void *s1, const void *s2, size_t size ); #define NVBOARDOS_KEY_MAX 128 #define NVBOARDOS_MEM_NONE 0x0 #define NVBOARDOS_MEM_READ 0x1 #define NVBOARDOS_MEM_WRITE 0x2 #define NVBOARDOS_MEM_EXECUTE 0x4 #define NVBOARDOS_MEM_READ_WRITE ( NVBOARDOS_MEM_READ | NVBOARDOS_MEM_WRITE ) typedef enum { NvBoardOsMemAttribute_Uncached = 0, NvBoardOsMemAttribute_WriteBack = 1, NvBoardOsMemAttribute_WriteCombined = 2, NvBoardOsMemAttribute_Force32 = 0x7FFFFFFF } NvBoardOsMemAttribute; NvError NvBoardOsPhysicalMemMap( NvPhysAddr phys, size_t size, NvBoardOsMemAttribute attrib, NvU32 flags, void **ptr ); void NvBoardOsPhysicalMemUnmap( void *ptr, size_t size ); NvError NvBoardOsMemoryAlloc(void **ptr, size_t size); void NvBoardOsMemoryFree(void *ptr, size_t size); NvError NvBoardOsGetConfigU32( const char *name, NvU32 *value ); void * NvBoardOsAlloc( size_t size ); void NvBoardOsFree( void *ptr ); typedef void (*NvBoardOsThreadFunction)( void *args ); NvError NvBoardOsThreadCreate( const char *name, NvBoardOsThreadFunction function, void *args, NvBoardOsThread *thread ); void NvBoardOsThreadJoin( NvBoardOsThread thread ); void NvBoardOsThreadYield( void ); NvError NvBoardOsSemaphoreCreate( const char *key, NvBoardOsSemaphore *semaphore, NvU32 value ); void NvBoardOsSemaphoreWait( NvBoardOsSemaphore semaphore ); void NvBoardOsSemaphoreSignal( NvBoardOsSemaphore semaphore ); void NvBoardOsSemaphoreDestroy( NvBoardOsSemaphore semaphore ); NvError nvBoard_PreDisplayInit(void); NvError nvBoard_PostDisplayInit(void); NvError nvBoard_PrePanelInit(void); NvError nvBoard_PostPanelInit(void); NvError nvBoard_PreDeviceInit(void); NvError nvBoard_PostDeviceInit(void); NvError nvBoard_PreSetMode(void); NvError nvBoard_PostSetMode(void); NvError nvBoard_PreOEMPowerHandlerVideoPowerOff(void); NvError nvBoard_PostOEMPowerHandlerVideoPowerOff(void); NvError nvBoard_PreOEMPowerHandlerVideoPowerOn(void); NvError nvBoard_PostOEMPowerHandlerVideoPowerOn(void); #ifdef __cplusplus } #endif #endif // NVBOARD_H