Home

User Manual - TEWS TECHNOLOGIES

image

Contents

1. Other returned error codes are system error conditions TDRV004 SW 42 VxWorks Device Driver Page 100 of 109 TEWS amp TECHNOLOGIES 5 3 14 FIO_TDRV004_WRITE_UCHAR This I O control function writes a number of unsigned char values to a Memory or I O area by using BYTE 8bit accesses The function specific control parameter arg is a pointer to a TDRV004_MEMIO_BUF structure This data buffer can be enlarged to the desired needs The data section must be included inside this structure typedef struct TDRV004 RESOURCE Resource unsigned long Offset unsigned long Size unsigned char pData 1 dynamically expandable TDRV004_MEMIO_BUF Resource Specifies the desired PCI resource to write to The TDRV004 RESOURCE enumeration contains values for all possible memory and I O areas Both first PCl Memory and PCI I O areas of the TDRV004 module are restricted and cannot be used by the application The second found PCl Memory area is named TDRV004_RES_MEM_2 the second PCI I O space found is named TDRV004_RES IO 2 and so on The Base Address Register BAR usage is programmable and can be changed by modifying the PLX9030 EEPROM Therefore the following table is just an example how the PCI Base Address Registers could be used BAR PCI Address Type TDRV004_RESOURCE 0 IO reserved TDRV004_RES_IO 1 1 MEM reserved TDRV004_RES MEM_1 2 MEM used by VHDL Example TDRV004_RES MEM 2 3 IO not implemented by default
2. unsigned char SpiAddr unsigned char SubAddr unsigned long len unsigned char pData 1 dynamically expandable TDRV004_SPI_BUF SpiAddr Specifies the Serial Programming Interface SPI address of the desired target The following values are possible refer to file tdrv004 h Symbol Value Description TDRV004_CLKADDR_EEPROM 0x68 Clock Generator EEPROM non volatile TDRV004_CLKADDR_SRAM 0x69 Clock Generator SRAM volatile TDRV004_CLKADDR_EEBLOCK1 0x40 EEPROM Bank 1 TDRV004_CLKADDR_EEBLOCK2 0x41 EEPROM Bank 2 TDRV004_CLKADDR_EEBLOCK3 0x42 EEPROM Bank 3 TDRV004_CLKADDR_EEBLOCK4 0x43 EEPROM Bank 4 TDRV004_CLKADDR_EEBLOCK5 0x44 EEPROM Bank 5 TDRV004_CLKADDR_EEBLOCK6 0x45 EEPROM Bank 6 TDRV004_CLKADDR_EEBLOCK7 0x46 EEPROM Bank 7 TDRV004_CLKADDR_EEBLOCK8 0x47 EEPROM Bank 8 SubAdar Specifies the sub address starting offset len This value specifies the amount of data items to read A maximum of 256 is allowed pData The values are copied to this buffer It must be large enough to hold the specified amount of data The data space must be located inside the structure no pointer allowed TDRV004 SW 42 VxWorks Device Driver Page 89 of 109 TEWS amp TECHNOLOGIES EXAMPLE include tdrv004 h int fd int BufferSize TDRV004_SPI_BUF pSpiBuf int retval read 5 bytes from EEPROM block 1 offset 0x00 allocate enough memory to hold the data structure read data
3. mIoBuf TDRV004_MEMIO_BUF malloc BufferSize mIoBuf gt Size 10 mIoBuf gt Resource TDRV004_RES_MEM_2 mloBuf gt Offset 0 lues unsigned short pMemIoBuf gt pData lues 0 0x0001 lues 1 0x0002 SW 42 VxWorks Device Driver Page 55 of 109 TEWS amp TECHNOLOGIES result tdrv004WriteU16 pDev pMemIoBuf if retval ERROR function succeeded else handle the error fFree pMemIoBuf RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual or a driver set code described below Function specific error codes will be described with the function Error code Description EINVAL The specified Offset Size exceeds the available memory or I O space EACCES The specified Resource is not available for access EBUSY The device is already busy with XSVF Reconfig or SPI action TDRV004 SW 42 VxWorks Device Driver Page 56 of 109 TEWS amp TECHNOLOGIES 3 2 16 tdrv004WriteU32 NAME tdrv004WriteU32 Write 32bit values to FPGA resource SYNOPSIS STATUS tdrv004WriteU32 TDRV004_DEV pDev TDRV004_MEMIO_BUF pMemloBuf DESCRIPTION This function writes a number of unsigned long 32bit values to a Memory or I O area by using DWORD 32bit accesses The data buffer can be enla
4. BufferSize sizeof TDRV004_SPI_BUF 5 sizeof unsigned char pSpiBuf TDRV004_SPI_BUF malloc BufferSize pSpiBuf gt SpiAddr TDRV004_CLKADDR_EEBLOCK1 pSpiBuf gt SubAddr 0x00 pSpiBuf gt len 5 retval ioctl fd FIO_TDRV004_SPIREAD int pSpiBuf if retval ERROR function succeeded else handle the error free pSpiBuf ERROR CODES Error code Description EINVAL The specified SubAddr len exceeds 256 or len is invalid EIO An error occurred during SPI access EBUSY The device is already busy with XSVF Reconfig or SPI action Other returned error codes are system error conditions TDRV004 SW 42 VxWorks Device Driver Page 90 of 109 TEWS amp TECHNOLOGIES 5 3 9 FIO_TDRV004_PLXWRITE This I O control function writes an unsigned short value to a specific PLX PCI9030 EEPROM memory offset The function specific control parameter arg is a pointer to a TDRV004_PLX_BUF structure typedef struct unsigned long Offset unsigned short Value TDRV004_PLX_BUF Offset Specifies the offset into the PLX9030 EEPROM where the supplied data word should be written The offset must be specified as even byte address Following offsets are available Offset Access 00h OCh R OEh R W 10h 26h R 28h 36h R W 38h 3Ah R 3Ch 4Ah R W 4Ch 4Eh R 50h 5Eh R W 60h 62h R 64h 7Eh R W 80h 86h R 88h FEh R W Ref
5. TEWS amp TECHNOLOGIES 5 3 13 FIO TDRV004_READ ULONG This I O control function reads a number of unsigned long values from a Memory or I O area by using DWORD 32bit accesses The function specific control parameter arg is a pointer to a TDRV004_MEMIO_BUF structure This data buffer can be enlarged to the desired needs The data section must be included inside this structure typedef struct TDRV004 RESOURCE Resource unsigned long Offset unsigned long Size unsigned char pData 1 dynamically expandable TDRV004_MEMIO_BUF Resource Specifies the desired PCI resource to read from The TDRV004_ RESOURCE enumeration contains values for all possible memory and I O areas Both first PCl Memory and PCI I O areas of the TDRV004 module are restricted and cannot be used by the application The second found PCl Memory area is named TDRV004_RES_MEMNM_2 the second PCI I O space found is named TDRV004_RES IO 2 and so on The Base Address Register usage is programmable and can be changed by modifying the PLX9030 EEPROM Therefore the following table is just an example how the PCI Base Address Registers could be used BAR PCI Address Type TDRV004_RESOURCE 0 IO reserved TDRV004_RES_IO 1 1 MEM reserved TDRV004_RES MEM_1 2 MEM used by VHDL Example TDRV004_RES MEM 2 3 IO not implemented by default TDRV004_RES 10 2 4 IO not implemented by default TDRV004_RES_IO 3 5 MEM notimplemented by default TDRV004_RES_MEM_3 The
6. The received values are copied into this buffer It must be large enough to hold the specified amount of data TDRV004 SW 42 VxWorks Device Driver Page 95 of 109 TEWS amp TECHNOLOGIES EXAMPLE include tdrv004 h int fd unsigned long BufferSize TDRVO04_MEMIO_BUF pMemIoBuf unsigned char pValues int retval read 50 bytes from MemorySpace 2 offset 0x00 allocate enough memory to hold the data structure read data BufferSize sizeof TDRVO04_MEMIO_BUF 50 sizeof unsigned char pMemIoBuf TDRVO04_MEMIO_BUF malloc BufferSize pMemIoBuf gt Size 50 pMemIoBuf gt Resource TDRVO04_RES MEM 2 pMemIoBuf gt Offset 0 retval ioctl fd FIO_TDRV004_READ_UCHAR int pMemIoBuf if retval ERROR function succeeded pValues unsigned char pMemIoBuf gt pData else handle the error free pMemIoBuf ERROR CODES Error code Description EINVAL The specified Offset Size exceeds the available memory or I O space EACCES The specified Resource is not available for access EBUSY The device is already busy with XSVF Reconfig or SPI action Other returned error codes are system error conditions TDRV004 SW 42 VxWorks Device Driver Page 96 of 109 TEWS amp TECHNOLOGIES 5 3 12 FIO_TDRV004_READ_USHORT This I O control function reads a number of unsigned short values from a Memory
7. x44 SwMatrix x45 _SwMatrix x46_SwMatrix unsigned char x47_DIV2SRCN TDRV004_CLOCK_PARAM DeviceAdadr Specifies the desired destination address The CY27EE16 clock generator provides several EEPROM banks as well as SRAM If TDRV004_CLKADR_SRANM is specified the values are directly stored inside the volatile RAM area and take effect immediately If TDRV004_CLKADR_EEPROM is specified the values are stored in the non volatile area of the clock generator and the CY27EE16 loads it after the next power up X09_CIkOE Specifies which clock outputs shall be enabled x0C_DIV1SRCN Specifies internal input source 1 and the corresponding frequency divider X10_InputCtrl Specifies value for the Input Pin Control register x40_CPumpPB Specifies value for Charge Pump and PB counter register x41_CPumpPB Specifies value for Charge Pump and PB counter register x42_POQent Specifies value for PO and Q counter register x44_SwMatrix Specifies value for Switching Matrix Register x45_SwMatrix Specifies value for Switching Matrix Register TDRV004 SW 42 VxWorks Device Driver Page 84 of 109 TEWS amp TECHNOLOGIES X46_SwMatrix Specifies value for Switching Matrix Register x47_DIV2SRCN Specifies internal input source 2 and the corresponding frequency divider Please refer to the Cypress CY27EE16 user manual for detailed explanation of the above register values Use Cypress CyberClocks Version R3 10 00 to determine the correct v
8. Size This value specifies the amount of data items to read pData The received values are copied into this buffer It must be large enough to hold the specified amount of data The data pointer is typecasted into an unsigned short pointer TDRV004 SW 42 VxWorks Device Driver Page 97 of 109 TEWS amp TECHNOLOGIES EXAMPLE include tdrv004 h int fd unsigned long BufferSize TDRVO04_MEMIO_BUF pMemIoBuf unsigned short pValues int retval read 50 16bit words from MemorySpace 2 offset 0x00 allocate enough memory to hold the data structure read data BufferSize sizeof TDRVO04_MEMIO_BUF 50 sizeof unsigned short pMemIoBuf TDRVO04_MEMIO_BUF malloc BufferSize pMemIoBuf gt Size 50 pMemIoBuf gt Resource TDRVO04_RES MEM 2 pMemIoBuf gt Offset 0 retval ioctl fd FIO_TDRV004_ READ _USHORT int pMemIoBuf if retval ERROR function succeeded pVvalues unsigned short pMemIoBuf gt pData else handle the error free pMemIoBuf ERROR CODES Error code Description EINVAL The specified Offset Size exceeds the available memory or I O space EACCES The specified Resource is not available for access EBUSY The device is already busy with XSVF Reconfig or SPI action Other returned error codes are system error conditions TDRV004 SW 42 VxWorks Device Driver Page 98 of 109
9. TECHNOLOGIES 2 1 Legacy vs VxBus Driver In later VxWorks 6 x releases the old VxWorks 5 x legacy device driver model was replaced by VxBus enabled device drivers Legacy device drivers are tightly coupled with the BSP and the board hardware The VxBus infrastructure hides all BSP and hardware differences under a well defined interface which improves the portability and reduces the configuration effort A further advantage is the improved performance of API calls by using the method interface and bypassing the VxWorks basic I O interface VxBus enabled device drivers are the preferred driver interface for new developments The checklist below will help you to make a decision which driver model is suitable and possible for your application Legacy Driver VxBus Driver VxWorks 5 x releases VxWorks 6 6 and later releases VxWorks 6 5 and earlier Witi ABUS PS Bug releases SMP systems only the VxBus i i VxWorks 6 x releases without driver is SMP satel VxBus PCI bus support TEWS TECHNOLOGIES recommends not using the VxBus Driver before VxWorks release 6 6 In previous releases required header files are missing and the support for 3 party drivers may not be available 2 2 VxBus Driver Installation Because Wind River doesn t provide a standard installation method for 3 party VxBus device drivers the installation procedure needs to be done manually In order to perform a manual installation extract all files
10. BufferSize pMemlIoBuf gt Size 50 pMemIoBuf gt Resource TDRVO04_RES_ MEM 2 pMemIoBuf gt Offset 0 result tdrv004ReadU32 pDev pMemIoBuf TDRV004 SW 42 VxWorks Device Driver Page 49 of 109 TEWS amp TECHNOLOGIES if result ERROR function succeeded pValues unsigned int pMemIoBuf gt pData else handle the error free pMemIoBuf RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual or a driver set code described below Function specific error codes will be described with the function Error code Description EINVAL The specified Offset Size exceeds the available memory or I O space EACCES The specified Resource is not available for access EBUSY The device is already busy with XSVF Reconfig or SPI action TDRV004 SW 42 VxWorks Device Driver Page 50 of 109 TEWS amp TECHNOLOGIES 3 2 14 tdrv004WriteU8 NAME tdrv004WriteU8 Write 8bit values to FPGA resource SYNOPSIS STATUS tdrv004WriteU8 TDRV004_DEV pDev TDRV004_MEMIO_BUF pMemloBuf DESCRIPTION This function writes a number of unsigned char 8bit values to a Memory or I O area by using BYTE 8bit accesses The data buffer can be enlarged to the desired needs The data section must be included i
11. Specifies the offset into the PLX PCI9030 EEPROM where the supplied data word should be read The offset must be specified as even byte address Following offsets are available Offset 00h OCh OEh 10h 26h 28h 36h 38h 3Ah 3Ch 4Ah 4Ch 4Eh 50h 5Eh 60h 62h 64h 7Eh 80h 86h 88h FEh Access R R W R R W R R W R R W R R W R R W Refer to the PLX PCI9030 User Manual for detailed information on these registers Value This value holds the retrieved 16bit word TDRV004 SW 42 VxWorks Device Driver Page 93 of 109 TEWS amp TECHNOLOGIES EXAMPLE include tdrv004 h int fd TDRVO004_PLX_BUF P1lxBuf int retval Read Subsystem ID PlxBuf Offset 0x0C retval ioctl fd FIO_TDRV004_PLXREAD int amp P1lxBuf if retval ERROR function succeeded printf SubsystemID 0x 04X n P1lxBuf Value else handle the error ERROR CODES Error code Description EINVAL The specified offset is invalid EBUSY The device is already busy with XSVF Reconfig or SPI action l Other returned error codes are system error conditions TDRV004 SW 42 VxWorks Device Driver Page 94 of 109 TEWS amp TECHNOLOGIES 5 3 11 FIO_TDRV004_READ_UCHAR This I O control function reads a number of unsigned char values from a Memory or I O area by using BYTE 8bit accesses The function specific contr
12. TECHNOLOGIES EXAMPLE include tdrv004 h int fd int BufferSize TDRV004_SPI_BUF pSpiBuf int retval write 5 bytes to EEPROM block 1 offset 0x00 allocate enough memory to hold the data structure write data ey BufferSize sizeof TDRVO04_SPI_BUF 5 sizeof unsigned char pSpiBuf TDRV0O04_SPI_BUF malloc BufferSize pSpiBuf gt SpiAddr TDRV004_CLKADDR_EEBLOCK1 pSpiBuf gt SubAddr 0x00 pSpiBuf gt len pSpiBuf gt pData 0 0x01 pSpiBuf gt pData 1 0x02 pSpiBuf gt pData 2 0x03 pSpiBuf gt pData 3 0x04 pSpiBuf gt pData 4 0x05 retval ioctl fd FIO_TDRV004_SPIWRITE int pSpiBuf if retval ERROR function succeeded else handle the error free pSpiBuf ERROR CODES Error code Description EINVAL The specified SubAddr len exceeds 256 or len is invalid EIO An error occurred during SPI access EBUSY The device is already busy with XSVF Reconfig or SPI action Other returned error codes are system error conditions TDRV004 SW 42 VxWorks Device Driver Page 88 of 109 TEWS amp TECHNOLOGIES 5 3 8 FIO_TDRV004_SPIREAD This I O control function reads up to 256 unsigned char values from a specific sub address of a Serial Programming Interface SPI address The function specific control parameter arg is a pointer to a TDRV004_SPI_BUF structure typedef struct
13. gt pData 0x00000001 0x00000002 pValues pValues 0 pvalues 1 ioctl fd FIO_TDRV004_WRITE retval ERROR retval if function succeeded else handle the error free pMemIoBuf _ULONG int pMemIoBuf ERROR CODES Error code Description EINVAL The specified Offset Size exceeds the available memory or I O space EACCES The specified Resource is not available for access EBUSY The device is already busy with XSVF Reconfig or SPI action Other returned error codes are system error conditions TDRV004 SW 42 VxWorks Device Driver Page 106 of 109 TENSE TECHNOLOGIES 5 3 17 FIO_TDRV004_CONFIGURE_INT This TDRV004 control function configures the polarity of the PLX PCI9030 interrupt sources The function specific control parameter arg is a pointer to an unsigned long value This value is an OR ed value using the following definitions only one value valid for each interrupt source Value Description TDRV004_LINT1_POLHIGH Local Interrupt Source 1 HIGH active TDRV004_LINT1_POLLOW Local Interrupt Source 1 LOW active TDRV004_LINT2_POLHIGH Local Interrupt Source 2 HIGH active TDRV004_LINT2_POLLOW Local Interrupt Source 2 LOW active EXAMPLE include tdrv004 h int fd int retval unsigned int IntConfig Setup LINT1 to LOW polarity and LINT2 to HIGH polarity IntConfig TDRV004_LINT1_POLLOW TDRV0O04_LINT2_P
14. Driver Page 17 of 109 TEWS amp TECHNOLOGIES 3 2 2 tdrv004XsvfPos NAME tdrv004XsvfPos Retrieve current play position in XSVF file SYNOPSIS STATUS tdrv004XsvfPos TDRV004_DEV pDev unsigned int pXsvfPos DESCRIPTION This function returns the number of the current processed byte in the XSVF file during programming This control function can be used to monitor the programming progress PARAMETERS pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function pXsvfPos This parameter specifies a pointer to an unsigned int value which receives the current processed XSVF byte TDRV004 SW 42 VxWorks Device Driver Page 18 of 109 TEWS amp TECHNOLOGIES EXAMPLE include tdrv004 h TDRVO0O04_DEV pDev STATUS result unsigned int XsvfPos Check XSVF position result tdrv004XsvfPos pDev amp Xsvf fPos if result ERROR function succeeded printf Current XSVF position ld n XsvfPos j else handle error RETURN VALUE OK if function succeeds or ERROR ERROR CODES This function returns no function specific error codes TDRV004 SW 42 VxWorks Device Driver Page 19 of 109 TEWS amp TECHNOLOGIES 3 2 3 tdrv004XsvfLastCommand NAME tdrv004XsvfLastCommand Get the last executed XSVF command SYNOPSIS STATUS tdrv004XsvfLastCommand
15. Handle error RETURNS A device descriptor number or ERROR If the function fails an error code will be stored in errno ERROR CODES Error codes can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual SEE ALSO ioLib basic I O routine open TDRV004 SW 42 VxWorks Device Driver Page 73 of 109 TEWS amp TECHNOLOGIES 5 2 close NAME close close a device or file SYNOPSIS STATUS close int fd DESCRIPTION This function closes opened devices PARAMETER fd This file descriptor specifies the device to be closed The file descriptor has been returned by the open function EXAMPLE int fd STATUS retval close the device ba retval close fd if retval ERROR Handle error TDRV004 SW 42 VxWorks Device Driver Page 74 of 109 TENSE TECHNOLOGIES RETURNS OK or ERROR If the function fails an error code will be stored in errno ERROR CODES Error codes can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual SEE ALSO ioLib basic I O routine close TDRV004 SW 42 VxWorks Device Driver Page 75 of 109 TEWS amp TECHNOLOGIES 5 3 ioctl NAME ioctl performs an I O control function SYNOPSIS include tdrv004 h int ioctl int fd int request
16. TDRV004_RES 10 2 4 IO not implemented by default TDRV004_RES_IO 3 5 MEM notimplemented by default TDRV004_RES_MEM_3 The PLX9030 default configuration utilizes only BARO to BAR2 Offset Specifies the offset into the memory or I O space specified by Resource Size This value specifies the amount of data items to write pData The values are copied from this buffer It must be large enough to hold the specified amount of data TDRV004 SW 42 VxWorks Device Driver Page 101 of 109 TEWS amp TECHNOLOGIES EXAMPLE include tdrv004 h int fd unsigned long BufferSize TDRVO04_MEMIO_BUF pMemIoBuf unsigned char pValues int retval write 10 byte to MemorySpace 2 offset 0x00 allocate enough memory to hold the data structure write data BufferSize sizeof TDRVO04_MEMIO_BUF 10 sizeof unsigned char pMemIoBuf TDRVO004_MEMIO_BUF malloc BufferSize pMemIoBuf gt Size 10 pMemIoBuf gt Resource TDRVO04_RES_ MEM 2 pMemIoBuf gt Offset 0 pValues unsigned char pMemIoBuf gt pData pValues 0 0x01 pValues 1 0x02 retval ioctl fd FIO_TDRV004_WRITE_UCHAR int pMemIoBuf if retval ERROR function succeeded else handle the error fFree pMemIoBuf ERROR CODES Error code Description EINVAL The specified Offset Size exceeds the available memory or I O space EACCES The specified Resou
17. TDRV004_RES_MEM_3 The PLX PCI9030 default configuration utilizes only BARO to BAR2 Offset Specifies the offset into the memory or I O space specified by Resource Size This value specifies the amount of data items to read pData The values are copied from this buffer It must be large enough to hold the specified amount of data EXAMPLE in clude tdrv004 h TDRV004_DEV pDev STATUS result TDRVO04_MEMIO_BUF pMemIoBuf unsigned int pValues int BufferSize kx k k E Buf pMe pMe pMe pMe pVa pVa pVa TDRV004 write 10 32bit dwords to MemorySpace 2 offset 0x00 allocate enough memory to hold the data structure write data ferSize sizeof TDRVO04_MEMIO_BUF 10 sizeof unsigned int mIoBuf TDRVO04_MEMIO_BUF malloc BufferSize mIoBuf gt Size 10 mIoBuf gt Resource TDRV004_RES_MEM_2 mloBuf gt Offset 0 lues unsigned int pMemIoBuf gt pData lues 0 0x00000001 lues 1 0x00000002 SW 42 VxWorks Device Driver Page 58 of 109 TEWS amp TECHNOLOGIES result tdrv004WriteU32 pDev pMemIoBuf if retval ERROR function succeeded else handle the error fFree pMemIoBuf RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error code set by the I O sy
18. The second found PCl Memory area is named TDRV004_RES_MEM_2 the second PCI I O space found is named TDRVO04_RES_IO 2 and so on The Base Address Register BAR usage is programmable and can be changed by modifying the PLX PCI9030 EEPROM Therefore the following table is just an example how the PCI Base Address Registers could be used TDRV004 SW 42 VxWorks Device Driver Page 42 of 109 BAR PCI Address Type IO reserved MEM reserved used by VHDL Example not implemented by default IO not implemented by default al Ajoin eio O not implemented by default TEWS amp TECHNOLOGIES TDRV004_ RESOURCE TDRV004_RES_IO_1 TDRV004_RES_MEM_1 TDRV004_RES_MEM_2 TDRV004_RES_IO_2 TDRV004_RES_IO_3 TDRV004_RES_MEM_3 TDRV004 SW 42 VxWorks Device Driver The PLX PCI9030 default configuration utilizes only BARO to BAR2 Offset Specifies the offset into the memory or I O space specified by Resource Size This value specifies the amount of data items to read pData The received values are copied into this buffer It must be large enough to hold the specified amount of data EXAMPLE include tdrv004 h TDRV004_DEV pDev STATUS result TDRVO04_MEMIO_BUF pMemIoBuf unsigned char pValues int BufferSize read 50 bytes from MemorySpace 2 offset 0x00 allocate enough memory to hold the data structure read data BufferSize sizeof TDRVO04_MEMIO_BUF 50 s
19. ccccccscssssecssscscecsceeeeeeseeeeeeeaeeeaeaeaeaeaeaeaeaeaeaeaeaeananaes 81 53 4 FIO TDRV004 RECONEIG vsisisiesssccssavascecsaatesnstensnsacieadannsnansanadauatonnvdanaasdcaiadsaavanaeadadeuatease 82 5 3 5 FIO _TDRV004 SETWAITSTATES ccccccccccsesssseceseeeceesesseeeceeeesceesesaeeeeeeeesceessaaeeeseaeess 83 5 3 6 FIO _TDRV004 SET CLOCK ciccccccccccccececsessesecesceseeesesaeaeceecesceeaaeeeseeseessessaeeeeeeeess 84 TDRV004 SW 42 VxWorks Device Driver Page 3 of 109 TEWS amp TECHNOLOGIES 5 3 7 FIO_TDRV004_SPIWRITE 1 ee ec eee eee eee eee saae cae eaeseaeeeaeeeaeeseeeseeeseeeseaeesaeeseesaeeaaes 87 5 3 8 FIO_TDRV004_SPIREAD 00 eee cece ene cette ee eaae caus cage ceaeeeaeseaeeseeeseeeseeeseaeeeaeesaeesneeeaaes 89 5 3 9 FIO_TDRV004_PLXWRITE eee cece eect eee cee cae eeaeceaeseaeseaeeseeeseeeseeeseaeesaeeeeesneesaaes 91 5 3 10 FIO_TDRV004_PLXREAD 1 0 0 ceneeeneeeee ener eeeeeseeeeeeeeeaeeeaeesaaeeaaesaeenaeeeaeseaeeeaeee 93 5 3 11 FIO_TDRV004_READ_UCHAR 1 00 eee eee eee eeee eters teen eeeeeeaeesaeesaeesaaesaeenaeseaeeeaeeeaeee 95 5 3 12 FIO_TDRV004_READ_USHORT 0 cee rioris 97 5 3 13 FIO_TDRV004_READ_ULONG uo ee eee eee eee eteneeee tees eaeeeaeesaesaeenaeeeaeseaeeeaeee 99 5 3 14 FIO_TDRV004_WRITE_UCHAR 1 00 eect ee eee eect eee eae eae seaeeeaeseneeneeeseneeeeeeags 101 5 3 15 FIO_TDRV004_WRITE_USHORT o eee eee eeeeeee eee see eae eras seaeeeaeseeeseeeseeeeeeeeaas 103 5 3 16 FIO_TDRV004_WRITE_
20. code set by the I O system see VxWorks Reference Manual or a driver set code described below Function specific error codes will be described with the function Error code Description EINVAL The specified offset is invalid or read only EBUSY The device is already busy with XSVF Reconfig or SPI action TDRV004 SW 42 VxWorks Device Driver Page 41 of 109 TEWS amp TECHNOLOGIES 3 2 11 tdrv004ReadU8 NAME tdrv004ReadU8 Read 8bit values from FPGA resource SYNOPSIS STATUS tdrv004ReadU8 TDRV004_DEV pDev TDRV004_MEMIO_BUF pMemloBuf DESCRIPTION This function reads a number of unsigned char 8bit values from a Memory or I O area by using BYTE 8bit accesses The data buffer can be enlarged to the desired needs The data section must be included inside the structure PARAMETERS pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function pMemloBuf This parameter specifies a pointer to a TDRV004_MEMIO_BUF structure typedef struct TDRV004 RESOURCE Resource unsigned long Offset unsigned long Size unsigned char pData 1 dynamically expandable TDRV004_MEMIO_BUF Resource Specifies the desired PCI resource to read from The TDRV004_RESOURCE enumeration contains values for all possible memory and I O areas Both first PCI Memory and PCI I O areas of the TDRV004 module are restricted and cannot be used by the application
21. default configuration utilizes only BARO to BAR2 Offset Specifies the offset into the memory or I O space specified by Resource Size This value specifies the amount of data items to read pData The received values are copied into this buffer It must be large enough to hold the specified amount of data EXAMPLE include tdrv004 h TDRV004_DEV pDev STATUS result TDRVO04_MEMIO_BUF pMemIoBuf unsigned short pValues int BufferSize read 50 16bit words from MemorySpace 2 offset 0x00 allocate enough memory to hold the data structure read data BufferSize sizeof TDRVO04_MEMIO_BUF 50 sizeof unsigned short pMemIoBuf TDRVO04_MEMIO_BUF malloc BufferSize pMemIoBuf gt Size 50 pMemIoBuf gt Resource TDRVO04_RES_ MEM 2 pMemIoBuf gt Offset 0 result tdrv004ReadU16 pDev pMemIoBuf TDRV004 SW 42 VxWorks Device Driver Page 46 of 109 TEWS amp TECHNOLOGIES if result ERROR function succeeded pValues unsigned short pMemIoBuf gt pData else handle the error free pMemIoBuf RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual or a driver set code described below Function specific error codes
22. dynamically expandable TDRV004_SPI_BUF TDRV004 SW 42 VxWorks Device Driver Page 30 of 109 SpiAddr TEWS amp TECHNOLOGIES Specifies the Serial Programming Interface SPI address of the desired target The following values are possible refer to file tdrv004 h Description Clock Generator EEPROM non volatile Clock Generator SRAM volatile EEPROM Bank 1 EEPROM Bank 2 EEPROM Bank 3 EEPROM Bank 4 EEPROM Bank 5 EEPROM Bank 6 EEPROM Bank 7 EEPROM Bank 8 This value specifies the amount of data items to write A maximum of 256 is allowed The values are copied from this buffer It must be large enough to hold the specified amount of data The data must be stored inside the structure no pointer allowed Symbol Value TDRV004_CLKADDR_EEPROM 0x68 TDRV004_CLKADDR_SRAM 0x69 TDRV004_CLKADDR_EEBLOCK1 0x40 TDRV004 CLKADDR_EEBLOCK2 0x41 TDRV004_CLKADDR_EEBLOCK3 0x42 TDRV004_CLKADDR_EEBLOCK4 0x43 TDRV004_CLKADDR_EEBLOCK5 0x44 TDRV004_CLKADDR_EEBLOCK6 0x45 TDRV004_CLKADDR_EEBLOCK7 0x46 TDRV004_CLKADDR_EEBLOCK8 0x47 SubAddr Specifies the sub address starting offset len pData EXAMPLE include tdrv004 h TDRV004_DEV pDev STATUS result TDRV004_SPI_BUF pSpiBuf int BufferSize TDRV004 SW 42 VxWorks Device Driver Page 31 of 109 TEWS amp TECHNOLOGIES write 5 bytes to EEPROM block 1 offset 0x00 allocate enough memory to hold the data structure
23. int arg DESCRIPTION Special I O operation that do not fit to the standard basic I O calls read write will be performed by calling the ioctl function PARAMETER fd This file descriptor specifies the device to be used The file descriptor has been returned by the open function request This argument specifies the function that shall be executed Following functions are defined Function Description FIO_TDRV004_XSVFPLAY Play an XSVF file for FPGA programming FIO_TDRV004_XSVFPOS Retrieve current play position in XSVF file FIO_TDRV004_XSVFLASTCMD Get the last executed XSVF command FIO_TDRV004_RECONFIG Trigger FPGA reconfiguration process FIO_TDRV004_ SETWAITSTATES Specify number of waitstates for programming FIO_TDRV004_SETCLOCK Set clock generator parameters FIO_TDRV004_SPIWRITE Write values to clock generator FIO_TDRV004_SPIREAD Read values from clock generator FIO_TDRV004_ PLXWRITE Write 16bit value to PLX PCI9030 EEPROM FIO_TDRV004_PLXREAD Read 16bit value from PLX PCI9030 EEPROM FIO_TDRV004_ READ _UCHAR Read 8bit values from FPGA resource FIO_TDRV004_READ_USHORT Read 16bit values from FPGA resource TDRV004 SW 42 VxWorks Device Driver Page 76 of 109 TEWS amp TECHNOLOGIES FIO_TDRV004_READ_ ULONG Read 32bit values from FPGA resource FIO_TDRV004_WRITE_UCHAR Write 8bit values to FPGA resource FIO_TDRV004_WRITE_USHORT Write 16bit values to FPGA resource FIO_TDRV004_WRITE_ULONG Write 32bit values to FPGA resource FIO
24. located in clock device using the Serial Programming Interface SPI Read write specific PLX9030 registers VVVVV The TDRV004 SW 42 supports the modules listed below TPMC630 Reconfigurable FPGA with PMC 64 TTL I O Lines or 32 Differential I O Lines TCP630 Reconfigurable FPGA with CompactPCl 64 TTL I O Lines or 32 Differential I O Lines In this document covers all supported modules and devices will be called TDRV004 Specials for certain devices will be advised To get more information about the features and use of TDRV004 devices it is recommended to read the manuals listed below TPMC630 product family User Manual TPMC630 product family Engineering Manual Cypress CY27EE16 User Manual TDRV004 SW 42 VxWorks Device Driver Page 5 of 109 TEWS amp TECHNOLOGIES 2 Installation Following files are located on the distribution media Directory path TDRV004 SW 42 TDRV004 SW 42 2 0 2 pdf PDF copy of this manual TDRV004 SW 42 VXBUS zip Zip compressed archive with VxBus driver sources TDRV004 SW 42 LEGACY zip Zip compressed archive with legacy driver sources fpgaexa zip FPGA example XSVF files ChangeLog txt Release history Release txt Release information The archive TDRV004 SW 42 VXBUS zip contains the following files and directories Directory path tews tdrv004 tdrvO04drv c TDRV004 device driver source tdrv004def h TDRV004 driver include file tdrv004 h TDRV004 include file for driver and appl
25. target contig comps src hwif Afterwards the vxbUsrCmdLine c file must be updated by invoking the appropriate make command C gt cd WindRiver vxworks 6 7 target 3rdparty tews tdrv004 C gt copy tdrv004 de Windriver vxworks 6 7 target config comps srce hwif C gt copy tdrv004 dr Windriver vxworks 6 7 target config comps srce hwif C gt cd Windriver vxworks 6 7 target config comps src hwif C gt make vxbUsrCmdLine c TDRV004 SW 42 VxWorks Device Driver Page 8 of 109 TEWS amp TECHNOLOGIES 2 3 Legacy Driver Installation 2 3 1 Include Device Driver in Tornado IDE Project For Including the TDRV004 SW 42 device driver into a Tornado IDE project follow the steps below 1 Extract all files from the archive TDRV004 SW 42 LEGACY zip to your project directory 2 Add the device drivers C files to your project Make a right click to your project in the Workspace window and use the Add Files topic A file select box appears and the driver files in the tdrv004 directory can be selected 3 Now the driver is included in the project and will be built with the project For a more detailed description of the project facility please refer to your Tornado User s Guide 2 3 2 Special Installation for Intel x86 based Targets The TDRV004 device driver is fully adapted for Intel x86 based targets This is done by conditional compilation directives inside the source code and controlled by the VxWorks
26. to increase the used waitstates with control function FIO_TDRV004_SETWAITSTATES refer to the corresponding section in this manual Additionally the CLK1 should not be lower than 10MHz for programming EXAMPLE include tdrv004 h TDRV004_DEV pDev STATUS result TDRVO004_XSVF_BUF oXsvfBuf int bufsize allocate enough memory about 3MB to hold XSVF content bufsize sizeof TDRV004_XSVF_BUF lt filesize gt sizeof unsigned char pXsvfBuf TDRV004_XSVF_BUF malloc bufsize read XSVF content from file and store it inside pXsvfBuf gt pDatal Y pXsvfBuf gt pData ue pxsvfBuf gt size start FPGA programming result tdrv004XsvfPlay pDev pXsvfBuf if result ERROR handle error free pXsvfBuf TDRV004 SW 42 VxWorks Device Driver Page 16 of 109 TENSE TECHNOLOGIES RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual or a driver set code described below Function specific error codes will be described with the function Error code Description EINVAL There was an error during XSVF processing EINTR The function was cancelled EBUSY The device is already busy with XSVF Reconfig or SPI action TDRV004 SW 42 VxWorks Device
27. DevCreate char name int devldx int funcType void pParam DESCRIPTION This routine adds the selected device to the VxWorks system The device hardware will be setup and prepared for use This function must be called before performing any I O request to this device PARAMETER name This string specifies the name of the device that will be used to identify the device for example for open calls devidx This index number specifies the device to add to the system If modules of the same type are installed the channel numbers will be advised in the order the VxWorks pciFindDevice function will find the devices Example A system with 2x TPMC630 10 and 1x TCP630 10 will assign the following device indices Module Device Index TPMC630 10 1 0 TPMC630 10 2 1 TCP630 10 2 TDRV004 SW 42 VxWorks Device Driver Page 68 of 109 TENSE TECHNOLOGIES funcType This parameter is unused and should be set to 0 pParam This parameter is unused and should be set to NULL EXAMPLE include tdrv004 h STATUS result Create the device tdrv004 0 for the first TDRV004 device result tdrv004DevCreate tdrv004 0 0 0 NULL if result OK Device successfully created else Error occurred when creating the device RETURNS OK or ERROR If the function fails an error code will be stored in errno ERROR CODES The error codes are s
28. ES 3 2 Device Access Functions 3 2 1 tdrv004XsvfPlay NAME tdrv004XsvfPlay Play an XSVF file for FPGA programming SYNOPSIS STATUS tdrv004XsvfPlay TDRV004_DEV pDev TDRV004_XSVF_BUF pXsvfBuf DESCRIPTION This function programs the FPGA with a supplied XSVF file For information on building an XSVF file please refer to the Engineering Documentation of the TDRV004 product family The device driver is not able to verify the supplied XSVF file content so please make sure that the supplied XSVF is of a valid file format PARAMETERS pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function pXsvfBuf This parameter specifies a pointer to a TDRV004_XSVF_BUF structure typedef struct unsigned long size unsigned char pData 1 _ dynamically expandable TDRV004_XSVF_BUF size Specifies the total size of the supplied XSVF data pData This dynamically expandable array holds the XSVF data The data must be included inside the TDRV004_XSVF_BUF structure TDRV004 SW 42 VxWorks Device Driver Page 15 of 109 TENSE TECHNOLOGIES PROGRAMMING HINTS Depending on the XSVF file there might be a waiting period of approx 15 seconds at the beginning of programming The programming of the delivered FPGA example design XSVF file should not take much longer than 1 minute depending on the system load If the programming fails try
29. For high interrupt load a customized device driver should be used which serves the module specific functionality directly on interrupt level PARAMETERS pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function Timeout This value specifies the amount of time to wait for the incoming interrupt event The timeout value is specified in system ticks To wait indefinitely specify 1 TDRV004 SW 42 VxWorks Device Driver Page 64 of 109 TEWS amp TECHNOLOGIES EXAMPLE include tdrv004 h TDRVO04_DEV pDev STATUS result int Timeout Wait at least 5 seconds for incoming interrupt ay Timeout 5 sysClkRateGet result tdrv004WaitForINT2 pDev Timeout if result ERROR function succeeded acknowledge interrupt source in FPGA logic Lays to clear the PLX PCI9030 Local Interrupt Source else handle error RETURN VALUE OK if function succeeds or ERROR ERROR CODES Error code Description ETIME The interrupt did not arrive before the specified timeout EBUSY There is already a job waiting for this interrupt TDRV004 SW 42 VxWorks Device Driver Page 65 of 109 TEWS amp TECHNOLOGIES 4 Legacy I O System Functions This chapter describes the legacy driver level interface to the I O system The purpose of these functions is to install the
30. OGIES 3 2 9 tdrv004PIxWrite NAME tdrv004PlIxWrite Write 16bit value to PLX PCI9030 EEPROM SYNOPSIS STATUS tdrv004PIxWrite TDRV004_DEV pDev TDRV004_PLX_BUF PlxBuf DESCRIPTION This function writes an unsigned short 16bit value to a specific PLX PCI9030 EEPROM memory offset Please note that the PLX9030 reloads the new configuration from the EEPROM after a PCI reset i e the system must be rebooted to make PLX PCI9030 dependent changes take effect PARAMETERS pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function pPIxBuf This parameter specifies a pointer to a TDRV004_PLX_BUF structure typedef struct unsigned long Offset unsigned short Value TDRV004_PLX_BUF TDRV004 SW 42 VxWorks Device Driver Page 36 of 109 TENSE TECHNOLOGIES Offset Specifies the offset into the PLX9030 EEPROM where the supplied data word should be written The offset must be specified as even byte address Following offsets are available Offset Access 00h OCh R OEh R W 10h 26h R 28h 36h R W 38h 3Ah R 3Ch 4Ah R W 4Ch 4Eh R 50h 5Eh R W 60h 62h R 64h 7Eh R W 80h 86h R 88h FEh R W Refer to the PLX PCI9030 User Manual for detailed information on these registers Value This value specifies a 16bit word that should be written to the spec
31. OLHIGH retval ioctl fd FIO_TDRV004_CONFIGURE_INT int amp IntConfig if retval ERROR handle the error ERROR CODES This ioctl function returns no function specific error codes TDRV004 SW 42 VxWorks Device Driver Page 107 of 109 TEWS amp TECHNOLOGIES 5 3 18 FIO_TDRV004_WAIT_FOR_INT1 This TDRV004 control function enables the corresponding interrupt source and waits for Local Interrupt Source 1 LINT1 to arrive After the interrupt has arrived this specific local interrupt source is disabled The function specific control parameter arg is a pointer to an int value containing the timeout in system ticks To wait indefinitely specify 1 as timeout parameter The delay between an incoming interrupt and the return of the described function is system dependent and is most likely several microseconds For high interrupt load a customized device driver should be used which serves the module specific functionality directly on interrupt level EXAMPLE include tdrv004 h int fd int retval int Timeout xx Wait at least 5 seconds for incoming interrupt ae Timeout 5 sysClkRateGet retval ioctl fd FIO_TDRV0O04 WAIT _FOR_INT1 int amp Timeout j if retval ERROR acknowledge interrupt source in FPGA logic EJ to clear the PLX PCI9030 Local Interrupt Source else handle the error ERROR CODES Error code De
32. PLX9030 default configuration utilizes only BARO to BAR2 Offset Specifies the offset into the memory or I O space specified by Resource Size This value specifies the amount of data items to read pData The received values are copied into this buffer It must be large enough to hold the specified amount of data The data pointer is typecasted into an unsigned long pointer TDRV004 SW 42 VxWorks Device Driver Page 99 of 109 TEWS amp TECHNOLOGIES EXAMPLE include tdrv004 h int fd unsigned long BufferSize TDRV0O04_MEMIO_BUF pMemIoBuf unsigned int pValues int retval read 50 32bit dwords from MemorySpace 2 offset 0x00 allocate enough memory to hold the data structure read data BufferSize sizeof TDRVO04_MEMIO_BUF 50 sizeof unsigned int pMemIoBuf TDRVO04_MEMIO_BUF malloc BufferSize pMemIoBuf gt Size 50 pMemIoBuf gt Resource TDRVO04_RES MEM 2 pMemIoBuf gt Offset 0 retval ioctl fd FIO_TDRV004_READ_ULONG int pMemIoBuf if retval ERROR function succeeded pValues unsigned int pMemIoBuf gt pData else handle the error free pMemIoBuf ERROR CODES Error code Description EINVAL The specified Offset Size exceeds the available memory or I O space EACCES The specified Resource is not available for access EBUSY The device is already busy with XSVF Reconfig or SPI action
33. S 4 4 tdrvO004Init NAME tdrvO07Init initialize TDRV004 driver and devices SYNOPSIS include tdrv004 h STATUS tdrv004Init void DESCRIPTION This function is used by the TDRV004 example application to install the driver and to add all available devices to the VxWorks system See also 3 1 1 tdrv004Openfor the device naming convention for legacy devices After calling this function it is not necessary to call tdrv004Drv and tdrv004DevCreate explicitly EXAMPLE include tdrv004 h STATUS result result tdrvO004Init if result ERROR Error handling TDRV004 SW 42 VxWorks Device Driver Page 71 of 109 TEWS amp TECHNOLOGIES 5 Basic I O Functions The VxWorks basic I O interface functions are useable with the TDRV004 legacy and VxBus enabled driver in a uniform manner 5 1 open NAME open open a device or file SYNOPSIS int open const char name int flags int mode DESCRIPTION Before I O can be performed to the TDRV004 device a file descriptor must be opened by invoking the basic I O function open PARAMETER name Specifies the device which shall be opened flags Not used mode Not used TDRV004 SW 42 VxWorks Device Driver Page 72 of 109 TEWS amp TECHNOLOGIES EXAMPLE int fd Open the device named tdrv004 0 for I O af fd open tdrv004 0 0 0 if fd ERROR
34. S RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual or a driver set code described below Function specific error codes will be described with the function Error code Description EINVAL It was tried to disable CLK1 This is not allowed EIO An error occurred during SPI access EBUSY The device is already busy with XSVF Reconfig or SPI action TDRV004 SW 42 VxWorks Device Driver Page 29 of 109 TEWS amp TECHNOLOGIES 3 2 7 tdrv004SpiWrite NAME tdrv004SpiWrite Write values to SPI storage SYNOPSIS STATUS tdrv004SpiWrite TDRV004_DEV pDev TDRV004_SPILBUF pSpiloBuf DESCRIPTION This function writes up to 256 unsigned char 8bit values to a specific sub address of a Serial Programming Interface SPI address The SPI storages are available in the clock generator device Do not use this control function to setup the clock generator Please use API function tdrv004SpiWrite instead PARAMETERS pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function pSpiloBuf This parameter specifies a pointer to a TDRV004_SPI_BUF structure typedef struct unsigned char SpiAddr unsigned char SubAddr unsigned long len unsigned char pData 1
35. TDRV004_DEV pDev unsigned int pXsvfLastCmd DESCRIPTION This function returns the number of the last executed XSVF command This value can be used to find errors inside the supplied XSVF file This value refers to the line inside the ASCII SVF file PARAMETERS pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function pXsvfLastCmd This parameter specifies a pointer to an unsigned int value which receives the last executed XSVF command line number of ASCII SVF file TDRV004 SW 42 VxWorks Device Driver Page 20 of 109 TEWS amp TECHNOLOGIES EXAMPLE include TDRV004_DEV STATUS unsigned int tdrv004 h pDev result XsvfLastCmd Check Last XSVF command result tdrv004XsvfLastCommand if result ERROR function succeeded printf Last XSVF command else handle error RETURN VALUE OK if function succeeds or ERROR ERROR CODES pDev amp XsvfLastCmd ld n XsvfLastCmd This function returns no function specific error codes TDRV004 SW 42 VxWorks Device Driver Page 21 of 109 TEWS amp TECHNOLOGIES 3 2 4 tdrv004Reconfigure NAME tdrv004Reconfigure Trigger FPGA reconfiguration process SYNOPSIS STATUS tdrv004Reconfigure TDRV004_DEV pDev DESCRIPTION This function starts the reconfiguration process of the FPGA This
36. TEWS amp The Embedded I O Company TECHNOLOGIES TDRV004 SW 42 VxWorks Device Driver Reconfigurable FPGA Version 2 0 x User Manual Issue 2 0 2 April 2011 TEWS TECHNOLOGIES GmbH Am Bahnhof 7 25469 Halstenbek Germany Phone 49 0 4101 40580 Fax 49 0 4101 4058 19 e mail info tews com www tews com TDRV004 SW 42 VxWorks Device Driver Reconfigurable FPGA Supported Modules This document contains TEWS amp TECHNOLOGIES information which is proprietary to TEWS TECHNOLOGIES GmbH Any reproduction without written permission is forbidden TEWS TECHNOLOGIES GmbH has made any effort to ensure that this manual is accurate and TPMC630 TCP630 complete However TEWS TECHNOLOGIES GmbH reserves the right to change the product described in this document at any time without notice TEWS TECHNOLOGIES GmbH is not liable for any damage arising out of the application or use of the device described herein 2006 2011 by TEWS TECHNOLOGIES GmbH Issue Description Date 1 0 0 First Issue May 04 2006 1 1 0 New module support tdrv004DevCreate error handling enhanced May 16 2007 Interrupt functions added New Address TEWS LLC 2 0 0 Support for VxBus and API description added December 17 2009 2 0 1 Legacy vs VxBus Driver modified March 26 2010 2 0 2 Layout Revision April 7 2011 TDRV004 SW 42 VxWorks Device Driver Page 2 of 109 TEWS amp TECHNOLOGIES Table of Contents 1 UP Oe TON i ccictac cee sa pi
37. ULONG oo eect eee eeee eee eee eae eeaeseaeeeeseeeneeeseeeeeeeegs 105 5 3 17 FIO_TDRV004_CONFIGURE_INT 0 0 eee eee creer eee eee ceae eae seaeseaeseeeneeeseeeeeeeeegs 107 5 3 18 FIO_TDRV004_WAIT_FOR_INT1 00 ee eeceeeeeeeeeeeeneeeneecnaeenaeseaeseaeseeeneeeseeeeeeeeags 108 5 3 19 FIO_TDRV004_WAIT_FOR_INT2 00 eee eeceeceeeeeeeeeneeeeeeaeeaeenaeseaeseaeseeeteeeseeeseeeesas 109 TDRV004 SW 42 VxWorks Device Driver Page 4 of 109 TEWS amp TECHNOLOGIES 1 Introduction The TRDV004 SW 42 release contains independent driver sources for the old legacy pre VxBus and the new VxBus enabled driver model The VxBus enabled driver is recommended for new developments with later VxWorks 6 x releases and mandatory for VxWorks SMP systems Both drivers legacy and VxBus share the same application programming interface API and device independent basic I O interface with open close and ioctl functions The basic I O interface is only for backward compatibility with existing applications and should not be used for new developments Both drivers invoke a mutual exclusion and binary semaphore mechanism to prevent simultaneous requests by multiple tasks from interfering with each other The TDRV004 SW 42 device driver supports the following features Program and reconfigure onboard FPGA Program onboard clock generator using the Serial Programming Interface SPI Read write FPGA registers 32bit 16bit 8bit Read write EEPROM blocks
38. _TDRV004_ CONFIGURE_INT Configure local interrupt source polarity FIO_TDRV004_WAIT_FOR_INT1 Wait for incoming Local Interrupt Source 1 FIO_TDRV004_WAIT_FOR_INT2 Wait for incoming Local Interrupt Source 2 arg This parameter depends on the selected function request How to use this parameter is described below with the function RETURNS OK or ERROR If the function fails an error code will be stored in errno ERROR CODES The error code can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual Function specific error codes will be described with the function SEE ALSO ioLib basic I O routine ioctl TDRV004 SW 42 VxWorks Device Driver Page 77 of 109 TEWS amp TECHNOLOGIES 5 3 1 FIO_TDRV004_XSVFPLAY This I O control function programs the FPGA with a supplied XSVF file The function specific control parameter arg is a pointer to a TDRV004_XSVF_BUF structure For information on building an XSVF file please refer to the Engineering Documentation of the TDRV004 product family The device driver is not able to verify the supplied XSVF file content so please make sure that the supplied XSVF is of a valid file format typedef struct unsigned long size unsigned char pData 1 dynamically expandable TDRV004_XSVF_BUF size Specifies the total size of the supplied XSVF data pData This dynamically expandable array holds
39. ady a job waiting for this interrupt TDRV004 SW 42 VxWorks Device Driver Page 109 of 109
40. ahavedaxasavecciatounccvinuonegsuawode uvaas aaa 13 3 2 Device ACCESS FUNCI NS oaa aama aa ar a aaa cece kha abe octet aAa e eaaa Aa aa a edbwebeckeeetine 15 gel tOrVOOAXS VIP LAY aa aE deste oes E A 15 3 2 2 LOMOO4EXSVIPOS a aeiiae eaaa aa aE aa aA aa a A a aaa E a aa EaR 18 3 2 3 tdrvO04XsvfLastCOMMand cccccesesssssssscseesseeeeeseeeseeeeeeeeeeeseaeaeaueeaeauaeaeaeaeaeaeaeaeaeaeananaes 20 3 2 4 tavo Reconfigure e ssisrsieassann innia aan aN S VAARAN RAAE ER SAA ESAE AR ATERS 22 3 25 tdrv004S tWaitstateS i co ccssecoccesvaseaccssecasadaneuaccrnacnccainstamncnsaanesaondcsanssiacvasndve Evaa 24 32 0 TOVO04 Set ClO CK iinne aaae aa araa NA NANA AAAA GASAN OEA 26 3 2 7 tdrvO04SPIWTt Seisin anaia lacsties gangevdesacsaunedabansvseestint EERE TERESE 30 32 8 tdrvO04SpiRead asses ccccscesdacevis senses quctexbateccasescauderssdeccsdys daueevdass eaund aeaa nE TEE LENE OSERE EEE ED eS 33 3 2 9 tdrvOO4PIXWTITE irinna inaen aaae a Aa aaa aaa A A EE gasiias aaa AA 36 3 2 10 TAPVOOA iddo E T A AEE 39 3 2 11 tdaryv004Read UE n a aaa aaa aaa aaa aaa a a aa aa E Aaa a OAE aaae 42 3 2 12 tdivO04ReadU I Oriori i aa aa a a a A aN 45 3 2 13 tOPVOO4 REAdU 32 ii sciesdictasiiasdcaveidaadevsiendvavesdisiassvacddavesdacianadedvavesditdususiuadeavadandenteimaddavadades 48 3 2 14 LOPVOOA Wit 8 icc ccievcaccessceciceiandacinsgguaaiacdacensusy caveingdbacevsniuteitordatuesrponaciimagaadesirgundateagales 51 3 2 15 tOPVOO4 WiitOU 1G ai isesdicsa
41. allDir vxworks 6 x target config comps Vx Works C gt cd WindRiver vxworks 6 7 target 3rdparty tews tdrv004 C gt copy 40tdrv004 cdf Windriver vxworks 6 7 target config comps vxWorks In VxWorks 6 7 and newer releases the kernel configuration tool scans the CDF file automatically and updates the CxrCat txt cache file to provide component parameter information for the kernel configuration tool as long as the timestamp of the copied CDF file is newer than the one of the CxrCat txt If your copy command preserves the timestamp force to update the timestamp by a utility such as touch In earlier VxWorks releases the CxrCat txt file may not be updated automatically In this case remove or rename the original CxrCat txt file and invoke the make command to force recreation of this file C gt cd Windriver vxworks 6 7 target config comps vxWorks C gt del CxrCat txt C gt make After successful completion of all steps above and restart of the Wind River Workbench the TDRV004 driver and API can be included in VxWorks projects by selecting the TEWS TDRV004 Driver and TEWS TDRV004 API components in the hardware default Device Drivers folder with the kernel configuration tool 2 2 1 Direct BSP Builds In development scenarios with the direct BSP build method without using the Workbench or the vxprj command line utility the TDRV004 configuration stub files must be copied to the directory installDir vxworks 6 x
42. alues This program is also part of the TPMC630 or TCP630 Engineering Documentation EXAMPLE include tdrv004 h int fd TDRVO004_CLOCK_PARAM ClockParam int retval Setup clock generator SRAM ae CLK1 50 0MHz CLK2 20 0MHz ae CLK3 10 0MHz CLK4 1 0MHz KR CLK5 0 2MHz CLK6 off ClockParam DeviceAddress TDRVO0O04_CLKADR_SRAM ClockParam x09_C1kOE Ox6f ClockParam x0C_DIV1SRCN 0x64 ClockParam x10_InputCtrl 0x50 ClockParam x40_CPumpPB 0xc0 ClockParam x41_CPumpPB 0x03 ClockParam x42_POQcnt 0x81 ClockParam x44_SwMatrix 0x42 ClockParam x45_SwMatrix 0x9f ClockParam x46_SwMatrix 0x3f ClockParam x47_DIV2SRCN 0xe4 retval ioctl fd FIO_TDRV0O04_SETCLOCK int amp ClockParam if retval ERROR function succeeded else handle the error TDRV004 SW 42 VxWorks Device Driver Page 85 of 109 TENSE TECHNOLOGIES ERROR CODES Error code Description EINVAL It was tried to disable CLK1 This is not allowed EIO An error occurred during SPI access EBUSY The device is already busy with XSVF Reconfig or SPI action Other returned error codes are system error conditions TDRV004 SW 42 VxWorks Device Driver Page 86 of 109 TEWS amp TECHNOLOGIES 5 3 7 FIO_TDRV004_SPIWRITE This I O control function writes up to 256 unsigned char values to a specific sub address of a Ser
43. amming Interface SPI address The SPI storages are available in the clock generator device PARAMETERS pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function pSpiloBuf This parameter specifies a pointer to a TDRV004_SPI_BUF structure typedef struct unsigned char SpiAddr unsigned char SubAddr unsigned long len unsigned char pData 1 _ dynamically expandable TDRV004_SPI_BUF TDRV004 SW 42 VxWorks Device Driver Page 33 of 109 SpiAddr TEWS amp TECHNOLOGIES Specifies the Serial Programming Interface SPI address of the desired target The following values are possible refer to file tdrv004 h Symbol TDRV004_CLKADDR_EEPROM TDRV004_CLKADDR_SRAM TDRV004_CLKADDR_EEBLOCK1 TDRV004_CLKADDR_EEBLOCK2 TDRV004_CLKADDR_EEBLOCK3 TDRV004_CLKADDR_EEBLOCK4 TDRV004_CLKADDR_EEBLOCK5 TDRV004_CLKADDR_EEBLOCK6 TDRV004_CLKADDR_EEBLOCK7 TDRV004_CLKADDR_EEBLOCK8 SubAdadr Value 0x68 0x69 0x40 0x41 0x42 0x43 0x44 0x45 0x46 0x47 Specifies the sub address starting offset len Description Clock Generator EEPROM non volatile Clock Generator SRAM volatile EEPROM Bank 1 EEPROM Bank 2 EEPROM Bank 3 EEPROM Bank 4 EEPROM Bank 5 EEPROM Bank 6 EEPROM Bank 7 EEPROM Bank 8 This value specifies the amount of data items to write A maximum of 256 is allowed pData The values are copied to this buffer It must be large eno
44. ce EE E weeieeenutanarubeeesmeetameumeetesant 5 2 INSTALLATION vaca co ctecccie cd cccnecceacedsnnuccccenexteavatetancdsnantncvenes inneancuanexvacucnctaseuscataneuacess 6 2 1 Legacy vs VX BUS DIVO caten iia cinns cocetaan snccen se cenatan saannnnienncndoanakendoehnectsnanusnanpenieeasnanstecdeehseatananuencnpens 7 2 2 VXBus Driver Installation n nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn nnmnnn nnmnnn nnmnnn nnmnnn nnmnnn nnmnnn nnmn 7 2 2 1 Direct BSP Builds oo ieee ececeeeceseeseeseeeeeeeseeseeeeeeeeeseseeeeeeeeeseeeseseeeeeeeeeeeeeseeeeeeeeeseseeees 8 2 3 Legacy Driver Installation 00 ccccccseeseeeeee cece ee eeneeeeeee seen ena neeeeeee seers na eaeeeeeseeeeaseneaeeeaeseeneeseneeneeees 9 2 3 1 Include Device Driver in Tornado IDE Project eee ceeeeceeeeeeeeceeeeeeeeeeeaeeeeetaeeeentaeeeeneaa 9 2 3 2 Special Installation for Intel x86 based Targets ccceccceeceeeeeeeeeeaeeeeneeseeeeeseaeeesaeeeeeeeees 9 2 3 3 System Resource Requirement cccccceesceceeeeeceeeeeeaeeeeeeeceeeeesaeeesaaeseeeeeseeeeseaeeeeeeeeenees 10 3 API DOCUMENTATION nsnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnannnnnnnnnnnnnnnnnnnnnnnnnnnnnnannnnnnnnnnnnnnnnnnnnnan 11 3 1 General Functions eea aea aa etek ees es cece dole hse eect ans ees divs ete ene 11 Bide TAPVOOA OPC EEATT EA sind peetapecececi A E asetvyesec pads a dhdeshatiideapiceceevia lee geiphanadl 11 Bil TOVO04 ClOSCiscincniniciaccistanncavancsacav
45. codes will be described with the function Error code Description EINVAL The specified Offset Size exceeds the available memory or I O space EACCES The specified Resource is not available for access EBUSY The device is already busy with XSVF Reconfig or SPI action TDRV004 SW 42 VxWorks Device Driver Page 53 of 109 TEWS amp TECHNOLOGIES 3 2 15 tdrv004WriteU16 NAME tdrv004WriteU16 Write 16bit values to FPGA resource SYNOPSIS STATUS tdrv004WriteU16 TDRV004_DEV pDev TDRV004_MEMIO_BUF pMemloBuf DESCRIPTION This function writes a number of unsigned short 16bit values to a Memory or I O area by using WORD 16bit accesses The data buffer can be enlarged to the desired needs The data section must be included inside the structure PARAMETERS pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function pMemloBuf This parameter specifies a pointer to a TDRV004_MEMIO_BUF structure typedef struct TDRV004 RESOURCE Resource unsigned long Offset unsigned long Size unsigned char pData 1 dynamically expandable TDRV004_MEMIO_BUF Resource Specifies the desired PCI resource to write to The TDRV004_ RESOURCE enumeration contains values for all possible memory and I O areas Both first PCl Memory and PCI I O areas of the TDRV004 module are restricted and cannot be used by the application The second found PCl Memor
46. control function must be called after the FPGA is programmed using tdrv004XsvfPlay The function returns after the reconfiguration is done or an error occurred PARAMETERS pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function EXAMPLE include tdrv004 h TDRV004_DEV pDev STATUS result Reconfigure FPGA 7 result tdrv004Reconfigure pDev if result ERROR function succeeded else handle error TDRV004 SW 42 VxWorks Device Driver Page 22 of 109 TENSE TECHNOLOGIES RETURN VALUE OK if function succeeds or ERROR ERROR CODES Error code Description EIO An error occurred during reconfiguration This may be caused by an invalid FPGA content located inside the XSVF file EBUSY The device is already busy with XSVF Reconfig or SPI action TDRV004 SW 42 VxWorks Device Driver Page 23 of 109 TEWS amp TECHNOLOGIES 3 2 5 tdrv004SetWaitstates NAME tdrv004SetWaitstates Specify number of waitstates for programming SYNOPSIS STATUS tdrv004SetWaitstates TDRV004 DEV pDev int WaitStates DESCRIPTION This function configures the driver to use a number of waitstates during XSVF and SPI programming This might be necessary if the local clock CLK1 of the onboard clock generator is configured to rather slow The local programmi
47. ction succeeded the error fFree pMemIoBuf ERROR CODES Error code Description EINVAL The specified Offset Size exceeds the available memory or I O space EACCES The specified Resource is not available for access EBUSY The device is already busy with XSVF Reconfig or SPI action Other returned error codes are system error conditions TDRV004 SW 42 VxWorks Device Driver Page 104 of 109 TEWS amp TECHNOLOGIES 5 3 16 FIO TDRV004_WRITE_ULONG This I O control function writes a number of unsigned long values to a Memory or I O area by using DWORD 32bit accesses The function specific control parameter arg is a pointer to a TDRV004_MEMIO_BUF structure This data buffer can be enlarged to the desired needs The data section must be included inside this structure typedef struct TDRV004 RESOURCE Resource unsigned long Offset unsigned long Size unsigned char pData 1 dynamically expandable TDRV004_MEMIO_BUF Resource Specifies the desired PCI resource to read from The TDRV004_ RESOURCE enumeration contains values for all possible memory and I O areas Both first PCl Memory and PCI I O areas of the TDRV004 module are restricted and cannot be used by the application The second found PCl Memory area is named TDRV004_RES_MEMNM_2 the second PCI I O space found is named TDRV004_RES IO 2 and so on The Base Address Register BAR usage is programmable and can be changed by
48. driver in the I O system add and initialize devices The legacy I O system functions are only relevant for the legacy TDRV004 driver For the VxBus enabled TDRV004 driver the driver will be installed automatically in the I O system and devices will be created as needed for detected modules 4 1 tdrv0O04Drv NAME tdrv004Drv installs the TDRV004 driver in the I O system SYNOPSIS include tdrv004 h STATUS tdrv004Drv void DESCRIPTION This function searches for devices on the PCI bus and installs the TDRV004 driver in the I O system A call to this function is the first thing the user has to do before adding any device to the system or performing any I O request EXAMPLE include tdrv004 h Initialize Driver status tdrv004Drv if status ERROR Error handling TDRV004 SW 42 VxWorks Device Driver Page 66 of 109 TENSE TECHNOLOGIES RETURNS OK or ERROR If the function fails an error code will be stored in errno ERROR CODES Error codes are only set by system functions The error codes are stored in errno and can be read with the function errnoGet SEE ALSO VxWorks Programmer s Guide I O System TDRV004 SW 42 VxWorks Device Driver Page 67 of 109 TEWS amp TECHNOLOGIES 4 2 tdrv004DevCreate NAME tdrv004DevCreate Add a TDRV004 device to the VxWorks system SYNOPSIS include tdrv004 h STATUS tdrv004
49. dy busy with XSVF Reconfig or SPI action Other returned error codes are system error conditions TDRV004 SW 42 VxWorks Device Driver Page 79 of 109 TENSE TECHNOLOGIES 5 3 2 FIO_TDRV004_XSVFPOS This I O control function returns the number of the current processed byte in the XSVF file during programming with TDRV004_IOCS_XSVFPLAY This control function can be used to monitor the programming progress The function specific control parameter arg is a pointer to an unsigned int value EXAMPLE include tdrv004 h int fd unsigned int XsvfPos int retval Execute ioctl function Ay retval ioctl fd FIO_TDRV0O04_XSVFPOS int amp XsvfPos if retval ERROR function succeeded printf Current XSVF position ld n XsvfPos else handle the error ERROR CODES This ioctl function returns no function specific error codes TDRV004 SW 42 VxWorks Device Driver Page 80 of 109 TENSE TECHNOLOGIES 5 3 3 FIO_TDRV004_XSVFLASTCMD This I O control function returns the number of the last executed XSVF command This value can be used to find errors inside the supplied XSVF file This value refers to the line inside the ASCII SVF file The function specific control parameter arg is a pointer to an unsigned int value EXAMPLE include tdrv004 h int fd unsigned int XsvfLastCmd int retval Execute ioctl funct
50. ent The timeout value is specified in system ticks To wait indefinitely specify 1 TDRV004 SW 42 VxWorks Device Driver Page 62 of 109 TEWS amp TECHNOLOGIES EXAMPLE include tdrv004 h TDRVO04_DEV pDev STATUS result int Timeout Wait at least 5 seconds for incoming interrupt ay Timeout 5 sysClkRateGet result tdrv004WaitForINT1 pDev Timeout if result ERROR function succeeded acknowledge interrupt source in FPGA logic Lays to clear the PLX PCI9030 Local Interrupt Source else handle error RETURN VALUE OK if function succeeds or ERROR ERROR CODES Error code Description ETIME The interrupt did not arrive before the specified timeout EBUSY There is already a job waiting for this interrupt TDRV004 SW 42 VxWorks Device Driver Page 63 of 109 TEWS amp TECHNOLOGIES 3 2 19 tdrvO04WaitForiINT2 NAME tdrv004WaitForINT2 Wait for incoming Local Interrupt Source 2 SYNOPSIS STATUS tdrv004WaitForINT2 TDRV004_DEV pDev int Timeout DESCRIPTION This function enables the corresponding interrupt source and waits for Local Interrupt Source 2 LINT2 to arrive After the interrupt has arrived this specific local interrupt source is disabled The delay between an incoming interrupt and the return of the described function is system dependent and is most likely several microseconds
51. er to the PLX PCI9030 User Manual for detailed information on these registers Value This value specifies a 16bit word that should be written to the specified offset Note that the PLX PCI9030 reloads the new configuration from the EEPROM after a PCI reset i e the system must be rebooted to make PLX PCI9030 dependent changes take effect TDRV004 SW 42 VxWorks Device Driver Page 91 of 109 TEWS amp TECHNOLOGIES EXAMPLE include tdrv004 h int fd TDRVO0O04_PLX_BUF P1lxBuf int retval Change the Subsystem Vendor ID to TEWS TECHNOLOGIES 0x1498 PlxBuf Offset 0x0E PlxBuf Value 0x1498 retval ioctl fd FIO_TDRV004_PLXWRITE int amp P1xBuf if retval ERROR function succeeded else handle the error ERROR CODES Error code Description EINVAL The specified offset is invalid or read only EBUSY The device is already busy with XSVF Reconfig or SPI action Other returned error codes are system error conditions TDRV004 SW 42 VxWorks Device Driver Page 92 of 109 5 3 10 FIO_TDRV004_PLXREAD TEWS amp TECHNOLOGIES This I O control function reads an unsigned short value from a specific PLX PCI9030 EEPROM memory offset The function specific control parameter arg is a pointer to a TDRV004_PLX_BUF structure typedef struct unsigned long Offset unsigned short Value TDRV004_PLX_BUF Offset
52. eserved TDRV004_RES MEM_1 2 MEM used by VHDL Example TDRV004_RES MEM 2 3 IO not implemented by default TDRV004_RES 10 2 4 IO not implemented by default TDRV004_RES_IO 3 5 MEM notimplemented by default TDRV004_RES_MEM_3 The PLX9030 default configuration utilizes only BARO to BAR2 Offset Specifies the offset into the memory or I O space specified by Resource Size This value specifies the amount of data items to write pData The values are copied from this buffer It must be large enough to hold the specified amount of data The data pointer is typecasted into an unsigned short pointer TDRV004 SW 42 VxWorks Device Driver Page 103 of 109 TEWS amp TECHNOLOGIES EXAMPLE include tdrv004 h int unsigned long fd BufferSize TDRVO04_MEMIO_BUF pMemIoBuf unsigned short int pValues retval write 10 16bit words to MemorySpace 2 offset 0x00 allocate enough memory to hold the data structure write data BufferSize sizeof TDRV004_MEMIO_BUF 10 sizeof unsigned short pMemIoBuf TDRVO04_MEMIO_BUF malloc BufferSize pMemIoBuf gt Size 10 pMemIoBuf gt Resource TDRVO04_RES_ MEM 2 pMemIoBuf gt O0ffset 0 pValues unsigned char pMemIoBuf gt pData pValues 0 0x0001 pValues 1 0x0002 retval ioctl fd FIO_TDRV004_WRITE_USHORT int pMemIoBuf if retval else handle ERROR fun
53. from the archive TDRV004 SW 42 VXBUS zip to the typical gn party directory installDir vxworks 6 x target 3rdparty whereas installDir must be substituted by the VxWorks installation directory After successful installation the TDRV004 device driver is located in the vendor and driver specific directory installDir vxworks 6 x target 3rdparty tews tdrv004 At this point the TDRV004 driver is not configurable and cannot be included with the kernel configuration tool in a Wind River Workbench project To make the driver configurable the driver library for the desired processer CPU and build tool TOOL must be built in the following way 1 Open a VxWorks development shell e g C WindRiver wrenv exe p vxworks 6 7 2 Change into the driver installation directory installDir vxworks 6 x target 3rdparty tews tdrv004 3 Invoke the build command for the required processor and build tool make CPU cpuName TOOL tool TDRV004 SW 42 VxWorks Device Driver Page 7 of 109 TENSE TECHNOLOGIES For Windows hosts this may look like this C gt cd WindRiver vxworks 6 7 target 3rdparty tews tdrv004 C gt make CPU PENTIUM4 TOOL diab To compile SMP enabled libraries the argument VXBUILD SMP must be added to the command line C gt make CPU PENTIUM4 TOOL diab VXBUILD SMP To integrate the TDRV004 driver with the VxWorks development tools Workbench the component configuration file 40tdrv004 cdf must be copied to the directory inst
54. global defined macro CPU_FAMILY If the content of this macro is equal to 80X86 special Intel x86 conforming code and function calls will be included The second problem for Intel x86 based platforms can t be solved by conditional compilation directives Due to the fact that some Intel x86 BSP s doesn t map PCI memory spaces of devices which are not used by the BSP the required device memory spaces can t be accessed To solve this problem a MMU mapping entry has to be added for the required TDRV004 PCI memory spaces prior the MMU initialization usrMmulInit is done The C source file tdrvO04pci c contains the function tdrv004Pcilnit This routine finds out all TDRV004 devices and adds MMU mapping entries for all used PCI memory spaces Please insert a call to this function after the PCI initialization is done and prior to MMU initialization usrMmulnit The right place to call the function tdrv004Pcilnit is at the end of the function sysHwinit in sysLib c it can be opened from the project Files window Be sure that the function is called prior to MMU initialization otherwise the TDRV004 PCI spaces remains unmapped and an access fault occurs during driver initialization Please insert the following call at a suitable place in sysLib c tdrv004PcilInit Modifying the sysLib c file will change the sysLib c in the BSP path Remember this for future projects and recompilations TDRV004 SW 42 VxWorks Device Dri
55. ial Programming Interface SPI address The function specific control parameter arg is a pointer to a TDRV004_SPI_BUF structure typedef struct unsigned char SpiAddr unsigned char SubAddr unsigned long len unsigned char pData 1 dynamically expandable TDRV004_SPI_BUF SpiAddr Specifies the Serial Programming Interface SPI address of the desired target The following values are possible refer to file tdrv004 h Symbol Value Description TDRV004_CLKADDR_EEPROM 0x68 Clock Generator EEPROM non volatile TDRV004_CLKADDR_SRAM 0x69 Clock Generator SRAM volatile TDRV004_CLKADDR_EEBLOCK1 0x40 EEPROM Bank 1 TDRV004_CLKADDR_EEBLOCK2 0x41 EEPROM Bank 2 TDRV004_CLKADDR_EEBLOCK3 0x42 EEPROM Bank 3 TDRV004_CLKADDR_EEBLOCK4 0x43 EEPROM Bank 4 TDRV004_CLKADDR_EEBLOCK5 0x44 EEPROM Bank 5 TDRV004_CLKADDR_EEBLOCK6 0x45 EEPROM Bank 6 TDRV004_CLKADDR_EEBLOCK7 0x46 EEPROM Bank 7 TDRV004_CLKADDR_EEBLOCK8 0x47 EEPROM Bank 8 SubAdar Specifies the sub address starting offset len This value specifies the amount of data items to write A maximum of 256 is allowed pData The values are copied from this buffer It must be large enough to hold the specified amount of data The data must be stored inside the structure no pointer allowed Do not use this control function to setup the clockgenerator Please use control function FIO_TDRV004_SETCLOCK instead TDRV004 SW 42 VxWorks Device Driver Page 87 of 109 TEWS amp
56. ication tdrv004api c TDRV004 API file pf_micro c XSVF player functions Platform Flash pf_micro h header file for XSVF player functions pf_lenval c special functions for XSVF player pf_lenval h header file for XSVF functions pf_ports c hardware layer for XSVF player pf_ports h header file for XSVF hardware layer Makefile Driver Makefile 40tdrv004 cadf Component description file for VxWorks development tools tdrv004 dc Configuration stub file for direct BSP builds tdrv004 dr Configuration stub file for direct BSP builds include tvxbHal h Hardware dependent interface functions and definitions apps tdrv004exa c Example application The archive TDRV004 SW 42 LEGACY zip contains the following files and directories Directory path tdrvO04 tdrv004drv c tdrv004def h tdrv004 h tdrv004api c tdrv004pci c TDRV004 device driver source TDRV004 driver include file TDRV004 include file for driver and application TDRV004 API file TDRV004 PCI MMU mapping for Intel x86 based targets tdrv004exa c Example application pf_micro c XSVF player functions Platform Flash pf_micro h header file for XSVF player functions pf_lenval c special functions for XSVF player pf_lenval h header file for XSVF functions pf_ports c hardware layer for XSVF player pf_ports h header file for XSVF hardware layer include tdhal h Hardware dependent interface functions and definitions TDRV004 SW 42 VxWorks Device Driver Page 6 of 109 TEWS amp
57. ified offset EXAMPLE include tdrv004 h TDRV004_DEV pDev STATUS result TDRV004_PLX_BUF P1lxBuf Change the Subsystem Vendor ID to TEWS TECHNOLOGIES PlxBuf Offset 0x0E PlxBuf Value 0x1498 result tdrv0O04PlxWrite pDev amp P1lxBuf if result ERROR handle the error 0x1498 TDRV004 SW 42 VxWorks Device Driver Page 37 of 109 TENSE TECHNOLOGIES RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual or a driver set code described below Function specific error codes will be described with the function Error code Description EINVAL The specified offset is invalid or read only EBUSY The device is already busy with XSVF Reconfig or SPI action TDRV004 SW 42 VxWorks Device Driver Page 38 of 109 TEWS amp TECHNOLOGIES 3 2 10 tdrv004PIxRead NAME tdrv004PlxRead Read 16bit value from PLX PCI9030 EEPROM SYNOPSIS STATUS tdrv004PIxRead TDRV004_DEV pDev TDRV004_PLX_BUF PlxBuf DESCRIPTION This function reads an unsigned short 16bit value from a specific PLX PCI9030 EEPROM memory offset PARAMETERS pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open functio
58. ile descriptor to device pDev tdrv0040Open tdrv004 0 if pDev NULL handle open error TDRV004 SW 42 VxWorks Device Driver Page 11 of 109 TEWS amp TECHNOLOGIES RETURNS A device descriptor pointer or NULL if the function fails An error code will be stored in errno ERROR CODES The error codes are stored in errno The error code is a standard error code set by the I O system TDRV004 SW 42 VxWorks Device Driver Page 12 of 109 3 1 2 td NAM rv004Close E tdrv004Close closes a device SYNOPSIS int tdrv004Close TDRV004_DEV_ pDev DESCRIPTION This function closes previously opened devices PARAMETERS pDev TEWS amp TECHNOLOGIES This value specifies the file descriptor pointer to the hardware module retrieved by a call to the corresponding open function EXAMPLE include tdrv004 h TDRVO004_DEV pDev int result ee CI A resul lose file descriptor to device t tdrv004Close pDev if result lt 0 handle close error TDRV004 SW 42 VxWorks Device Driver Page 13 of 109 TEWS amp TECHNOLOGIES RETURNS Zero or 1 if the function fails An error code will be stored in errno ERROR CODES The error codes are stored in errno The error code is a standard error code set by the I O system TDRV004 SW 42 VxWorks Device Driver Page 14 of 109 TEWS amp TECHNOLOGI
59. ion xy retval ioctl fd FIO_TDRV004_ XSVFLASTCMD int amp XsvfLastCmd if retval ERROR function succeeded printf Last XSVF command ld n XsvfLastCmd else handle the error ERROR CODES This ioctl function returns no function specific error codes TDRV004 SW 42 VxWorks Device Driver Page 81 of 109 TENSE TECHNOLOGIES 5 3 4 FIO_TDRV004_RECONFIG This I O control function starts the reconfiguration process of the FPGA This control function must be called after the FPGA is programmed using FIO_TDRV004_XSVFPLAY The function returns after the reconfiguration is done or an error occurred The function specific control parameter arg is not used for this function EXAMPLE include tdrv004 h int fd int retval Execute ioctl function aif retval ioctl fd FIO_TDRVO04_RECONFIG 0 if retval ERROR function succeeded else handle the error ERROR CODES Error code Description EIO An error occurred during reconfiguration This may be caused by an invalid FPGA content located inside the XSVF file EBUSY The device is already busy with XSVF Reconfig or SPI action Other returned error codes are system error conditions TDRV004 SW 42 VxWorks Device Driver Page 82 of 109 TENSE TECHNOLOGIES 5 3 5 FIO_TDRV004_SETWAITSTATES This I O control function configures the driver to use a number
60. is named TDRV004_RES_MEM_2 the second PCI I O space found is named TDRVO04_RES_IO 2 and so on The Base Address Register BAR usage is programmable and can be changed by modifying the PLX PCI9030 EEPROM Therefore the following table is just an example how the PCI Base Address Registers could be used TDRV004 SW 42 VxWorks Device Driver Page 48 of 109 BAR PCI Address Type IO reserved MEM reserved used by VHDL Example not implemented by default IO not implemented by default alajn eio O not implemented by default TEWS amp TECHNOLOGIES TDRV004_ RESOURCE TDRV004_RES_IO_1 TDRV004_RES_MEM_1 TDRV004_RES_MEM_2 TDRV004_RES_IO_2 TDRV004_RES_IO_3 TDRV004_RES_MEM_3 The PLX PCI9030 default configuration utilizes only BARO to BAR2 Offset Specifies the offset into the memory or I O space specified by Resource Size This value specifies the amount of data items to read pData The received values are copied into this buffer It must be large enough to hold the specified amount of data EXAMPLE include tdrv004 h TDRV004_DEV pDev STATUS result TDRVO04_MEMIO_BUF pMemIoBuf unsigned int pValues int BufferSize read 50 32bit dwords from MemorySpace 2 offset 0x00 x allocate enough memory to hold the data structure read data y BufferSize sizeof TDRV004_MEMIO_BUF 50 sizeof unsigned int pMemIoBuf TDRVO004_MEMIO_BUF malloc
61. izeof unsigned char pMemIoBuf TDRVO04_MEMIO_BUF malloc BufferSize pMemIoBuf gt Size 50 pMemIoBuf gt Resource TDRVO04_RES_ MEM 2 pMemIoBuf gt Offset 0 result tdrv004Readus pDev pMemIoBuf Page 43 of 109 TEWS amp TECHNOLOGIES if result ERROR function succeeded pValues unsigned char pMemIoBuf gt pData else handle the error free pMemIoBuf RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual or a driver set code described below Function specific error codes will be described with the function Error code Description EINVAL The specified Offset Size exceeds the available memory or I O space EACCES The specified Resource is not available for access EBUSY The device is already busy with XSVF Reconfig or SPI action TDRV004 SW 42 VxWorks Device Driver Page 44 of 109 TEWS amp TECHNOLOGIES 3 2 12 tdrv004ReadU16 NAME tdrv004ReadU16 Read 16bit values from FPGA resource SYNOPSIS STATUS tdrv004ReadU16 TDRV004_DEV pDev TDRV004_MEMIO_BUF pMemloBuf DESCRIPTION This function reads a number of unsigned short 16bit values from a Memory or I O area by using WORD 16bit accesses The data buffer can be enlarged to the desired needs The data sec
62. modifying the PLX9030 EEPROM Therefore the following table is just an example how the PCI Base Address Registers could be used BAR PCI Address Type TDRV004_RESOURCE 0 IO reserved TDRV004_RES_IO 1 1 MEM reserved TDRV004_RES MEM_1 2 MEM used by VHDL Example TDRV004_RES_MEM_2 3 IO not implemented by default TDRV004_RES 10 2 4 IO not implemented by default TDRV004_RES_IO _3 5 MEM not implemented by default TDRV004_RES_ MEM_3 The PLX9030 default configuration utilizes only BARO to BAR2 Offset Specifies the offset into the memory or I O space specified by Resource Size This value specifies the amount of data items to write pData The values are copied from this buffer It must be large enough to hold the specified amount of data The data pointer is typecasted into an unsigned long pointer TDRV004 SW 42 VxWorks Device Driver Page 105 of 109 TEWS amp TECHNOLOGIES EXAMPLE include tdrv004 h int fd unsigned long BufferSize TDRV004_MEMIO_BUF unsigned int pMemIoBuf pValues int retval write 10 32bit dwords to MemorySpace 2 offset 0x00 allocate enough memory to hold the data structure write data BufferSize sizeof TDRVO04_MEMIO_BUF 10 sizeof unsigned int pMemIoBuf TDRVO004_MEMIO_BUF malloc BufferSize pMemIoBuf gt Size 10 pMemIoBuf gt Resource TDRVO04_RES_ MEM 2 pMemIoBuf gt Offset 0 unsigned int pMemIoBuf
63. n pPIxBuf This parameter specifies a pointer to a TDRV004_PLX_BUF structure typedef struct unsigned long Offset unsigned short Value TDRV004_PLX_BUF TDRV004 SW 42 VxWorks Device Driver Page 39 of 109 TENSE TECHNOLOGIES Offset Specifies the offset into the PLX PCI9030 EEPROM where the supplied data word should be read The offset must be specified as even byte address Following offsets are available Offset Access 00h OCh R OEh R W 10h 26h R 28h 36h R W 38h 3Ah R 3Ch 4Ah R W 4Ch 4Eh R 50h 5Eh R W 60h 62h R 64h 7Eh R W 80h 86h R 88h FEh R W Refer to the PLX PCI9030 User Manual for detailed information on these registers Value This value holds the retrieved 16bit word EXAMPLE include tdr TDRV004_DEV STATUS TDRVO04_PLX_BUF v004 h pDev result PlxBuf x Read Subsystem ID PlxBuf Offset result tdrv004P1xRead 0x0C if result ERROR function succeeded printf else handl SubsystemID e the error pDev amp P1xBuf PlxBuf Value TDRV004 SW 42 VxWorks Device Driver Page 40 of 109 TENSE TECHNOLOGIES RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error
64. ng interface is clocked with this frequency which might result in errors during programming for low CLK1 frequencies and a small amount of waitstates The system architecture existing PCI to PCI bridges might also have an impact PARAMETERS pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function WaitStates This parameter specifies the number of waitstates to be used for XSVF programming Valid values are 1 to 1000 TDRV004 SW 42 VxWorks Device Driver Page 24 of 109 TEWS amp TECHNOLOGIES EXAMPLE include tdrv004 h TDRV004_DEV pDev STATUS result int WaitStates Configure driver to use 3 waitstates WaitStates 3 result tdrv004SetWaitstates pDev WaitStates if result ERROR function succeeded else handle error RETURN VALUE OK if function succeeds or ERROR ERROR CODES This function returns no function specific error codes TDRV004 SW 42 VxWorks Device Driver Page 25 of 109 TEWS amp TECHNOLOGIES 3 2 6 tdrv004SetClock NAME tdrv004SetClock Set clock generator parameters SYNOPSIS STATUS tdrv004SetClock TDRV004_DEV pDev TDRV004_CLOCK_PARAM pClockParam DESCRIPTION This function configures the onboard clock generator PARAMETERS pDev This parameter specifies the device descriptor to the hardware module retrieved by a call
65. nside the structure PARAMETERS pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function pMemloBuf This parameter specifies a pointer to a TDRV004_MEMIO_BUF structure typedef struct TDRV004 RESOURCE Resource unsigned long Offset unsigned long Size unsigned char pData 1 dynamically expandable TDRV004_MEMIO_BUF Resource Specifies the desired PCI resource to write to The TDRV004_ RESOURCE enumeration contains values for all possible memory and I O areas Both first PCl Memory and PCI I O areas of the TDRV004 module are restricted and cannot be used by the application The second found PCl Memory area is named TDRV004_RES_MEM_2 the second PCI I O space found is named TDRV004_RES_IO_2 and so on The Base Address Register BAR usage is programmable and can be changed by modifying the PLX PCI9030 EEPROM Therefore the following table is just an example how the PCI Base Address Registers could be used TDRV004 SW 42 VxWorks Device Driver Page 51 of 109 TENSE TECHNOLOGIES BAR PCI Address Type TDRV004_RESOURCE 0 IO reserved TDRV004_RES_ IO_1 1 MEM reserved TDRV004_ RES_MEM_1 2 MEM used by VHDL Example TDRV004_RES_MEM_2 3 IO not implemented by default TDRV004_RES_IO_2 4 IO not implemented by default TDRV004_RES_IO 3 5 MEM notimplemented by default TDRV004_RES_MEM_3 The PLX PCI9030 default configuration utilizes onl
66. nsigned int IntConfig Setup LINT1 to LOW polarity and LINT2 to HIGH polarity IntConfig TDRV0O04_LINT1_POLLOW TDRVO04_LINT2_POLHIGH result tdrv004ConfigureInterrupts pDev if result ERROR function succeeded else handle error RETURN VALUE OK if function succeeds or ERROR IntConfig ERROR CODES Error code Description EINVAL Invalid interrupt configuration specified TDRV004 SW 42 VxWorks Device Driver Page 61 of 109 TEWS amp TECHNOLOGIES 3 2 18 tdrv004WaitForiINT1 NAME tdrv004WaitForINT1 Wait for incoming Local Interrupt Source 1 SYNOPSIS STATUS tdrv004WaitForINT 1 TDRV004_DEV pDev int Timeout DESCRIPTION This function enables the corresponding interrupt source and waits for Local Interrupt Source 1 LINT1 to arrive After the interrupt has arrived this specific local interrupt source is disabled The delay between an incoming interrupt and the return of the described function is system dependent and is most likely several microseconds For high interrupt load a customized device driver should be used which serves the module specific functionality directly on interrupt level PARAMETERS pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function Timeout This value specifies the amount of time to wait for the incoming interrupt ev
67. of waitstates during XSVF and SPI programming This might be necessary if the local clock CLK1 of the onboard clock generator is configured to rather slow The local programming interface is clocked with this frequency which might result in errors during programming for low CLK1 frequencies and a small amount of waitstates The system architecture existing PClI to PCI bridges might also have an impact The function specific control parameter arg is a pointer to an unsigned int value Valid values are 1 to 1000 EXAMPLE include tdrv004 h int fd unsigned long WaitStates int retval configure driver to use 3 waitstates WaitStates 3 retval ioctl fd FIO_TDRV0O04_ SETWAITSTATES int amp WaitStates if retval ERROR function succeeded else handle the error ERROR CODES This ioctl function returns no function specific error codes TDRV004 SW 42 VxWorks Device Driver Page 83 of 109 TEWS amp TECHNOLOGIES 5 3 6 FIO_TDRV004_SETCLOCK This I O control function configures the onboard clock generator The function specific control parameter arg is a pointer to a TDRV004_CLOCK_PARAM structure typedef struct unsigned char DeviceAddr unsigned char x09_CIkOE unsigned char x0C_DIV1SRCN unsigned char x10_InputCtrl unsigned char x40_CPumpPB unsigned char x41_CPumpPB unsigned char unsigned char unsigned char unsigned char x42_POQent
68. ol parameter arg is a pointer to a TDRV004_MEMIO_BUF structure This data buffer can be enlarged to the desired needs The data section must be included inside this structure typedef struct TDRV004 RESOURCE Resource unsigned long Offset unsigned long Size unsigned char pData 1 dynamically expandable TDRV004_MEMIO_BUF Resource Specifies the desired PCI resource to read from The TDRV004_ RESOURCE enumeration contains values for all possible memory and I O areas Both first PCl Memory and PCI I O areas of the TDRV004 module are restricted and cannot be used by the application The second found PCl Memory area is named TDRV004_RES_MEMNM_2 the second PCI I O space found is named TDRV004_RES IO 2 and so on The Base Address Register BAR usage is programmable and can be changed by modifying the PLX9030 EEPROM Therefore the following table is just an example how the PCI Base Address Registers could be used BAR PCI Address Type TDRV004_RESOURCE 0 IO reserved TDRV004_RES_IO 1 1 MEM reserved TDRV004_RES MEM_1 2 MEM used by VHDL Example TDRV004_RES MEM 2 3 IO not implemented by default TDRV004_RES 10 2 4 IO not implemented by default TDRV004_RES_IO 3 5 MEM notimplemented by default TDRV004_RES_MEM_3 The PLX9030 default configuration utilizes only BARO to BAR2 Offset Specifies the offset into the memory or I O space specified by Resource Size This value specifies the amount of data items to read pData
69. or I O area by using WORD 16bit accesses The function specific control parameter arg is a pointer to a TDRV004_MEMIO_BUF structure This data buffer can be enlarged to the desired needs The data section must be included inside this structure typedef struct TDRV004 RESOURCE Resource unsigned long Offset unsigned long Size unsigned char pData 1 dynamically expandable TDRV004_MEMIO_BUF Resource Specifies the desired PCI resource to read from The TDRV004_ RESOURCE enumeration contains values for all possible memory and I O areas Both first PCl Memory and PCI I O areas of the TDRV004 module are restricted and cannot be used by the application The second found PCl Memory area is named TDRV004_RES_MEMNM_2 the second PCI I O space found is named TDRV004_RES IO 2 and so on The Base Address Register BAR usage is programmable and can be changed by modifying the PLX9030 EEPROM Therefore the following table is just an example how the PCI Base Address Registers could be used BAR PCI Address Type TDRV004_RESOURCE 0 IO reserved TDRV004_RES_IO 1 1 MEM reserved TDRV004_RES MEM_1 2 MEM used by VHDL Example TDRV004_RES MEM 2 3 IO not implemented by default TDRV004_RES 10 2 4 IO not implemented by default TDRV004_RES_IO 3 5 MEM notimplemented by default TDRV004_RES_MEM_3 The PLX9030 default configuration utilizes only BARO to BAR2 Offset Specifies the offset into the memory or I O space specified by Resource
70. r X45 SwMatrix Specifies value for Switching Matrix Register X46_SwMatrix Specifies value for Switching Matrix Register x47_DIV2SRCN Specifies internal input source 2 and the corresponding frequency divider Please refer to the Cypress CY27EE16 user manual for detailed explanation of the above register values Use Cypress CyberClocks Version R3 10 00 to determine the correct values This program is also part of the TPMC630 or TCP630 Engineering Documentation TDRV004 SW 42 VxWorks Device Driver Page 27 of 109 TENSE TECHNOLOGIES EXAMPLE include tdrv004 h TDRV004_DEV pDev STATUS result TDRVO004_CLOCK_PARAM ClockParam Setup clock generator SRAM ER CLK1 50 0MHz CLK2 20 0MHz KR CLK3 10 0MHz CLK4 1 0MHz EE CLK5 0 2MHz CLK6 off Ra ClockParam DeviceAddress TDRVO0O04_CLKADR_SRAM ClockParam x09_C1kOE Ox6f ClockParam x0C_DIV1SRCN 0x64 ClockParam x10_InputCtrl 0x50 ClockParam x40_CPumpPB 0xc0 ClockParam x41_CPumpPB 0x03 ClockParam x42_POQcnt 0x81 ClockParam x44_SwMatrix 0x42 ClockParam x45_SwMatrix 0x9f ClockParam x46_SwMatrix 0x3f ClockParam x47_DIV2SRCN 0xe4 start FPGA programming aa result tdrv004SetClock pDev amp ClockParam if result ERROR function succeeded else handle the error TDRV004 SW 42 VxWorks Device Driver Page 28 of 109 TENSE TECHNOLOGIE
71. rce is not available for access EBUSY The device is already busy with XSVF Reconfig or SPI action Other returned error codes are system error conditions TDRV004 SW 42 VxWorks Device Driver Page 102 of 109 TEWS amp TECHNOLOGIES 5 3 15 FIO_TDRV004_WRITE_USHORT This I O control function writes a number of unsigned short values to a Memory or I O area by using WORD 16bit accesses The function specific control parameter arg is a pointer to a TDRV004_MEMIO_BUF structure This data buffer can be enlarged to the desired needs The data section must be included inside this structure typedef struct TDRV004 RESOURCE Resource unsigned long Offset unsigned long Size unsigned char pData 1 dynamically expandable TDRV004_MEMIO_BUF Resource Specifies the desired PCI resource to read from The TDRV004_ RESOURCE enumeration contains values for all possible memory and I O areas Both first PCl Memory and PCI I O areas of the TDRV004 module are restricted and cannot be used by the application The second found PCl Memory area is named TDRV004_RES_MEM_2 the second PCI I O space found is named TDRV004_RES IO 2 and so on The Base Address Register BAR usage is programmable and can be changed by modifying the PLX9030 EEPROM Therefore the following table is just an example how the PCI Base Address Registers could be used BAR PCI Address Type TDRV004_RESOURCE 0 IO reserved TDRV004_RES_IO 1 1 MEM r
72. rged to the desired needs The data section must be included inside the structure PARAMETERS pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function pMemloBuf This parameter specifies a pointer to a TDRV004_MEMIO_BUF structure typedef struct TDRV004 RESOURCE Resource unsigned long Offset unsigned long Size unsigned char pData 1 dynamically expandable TDRV004_MEMIO_BUF Resource Specifies the desired PCI resource to write to The TDRV004_ RESOURCE enumeration contains values for all possible memory and I O areas Both first PCl Memory and PCI I O areas of the TDRV004 module are restricted and cannot be used by the application The second found PCl Memory area is named TDRV004_RES_MEM_2 the second PCI I O space found is named TDRV004_RES_IO_2 and so on The Base Address Register BAR usage is programmable and can be changed by modifying the PLX PCI9030 EEPROM Therefore the following table is just an example how the PCI Base Address Registers could be used TDRV004 SW 42 VxWorks Device Driver Page 57 of 109 BAR PCI Address Type IO reserved MEM reserved used by VHDL Example not implemented by default IO not implemented by default alajn eio O not implemented by default TEWS amp TECHNOLOGIES TDRV004_ RESOURCE TDRV004_RES_IO_1 TDRV004_RES_MEM_1 TDRV004_RES_MEM_2 TDRV004_RES_IO_2 TDRV004_RES_IO_3
73. scription ETIME The interrupt did not arrive before the specified timeout EBUSY There is already a job waiting for this interrupt TDRV004 SW 42 VxWorks Device Driver Page 108 of 109 TEWS amp TECHNOLOGIES 5 3 19 FIO_TDRV004_WAIT_FOR_INT2 This TDRVO004 control function enables the corresponding interrupt source and waits for Local Interrupt Source 2 LINT2 to arrive After the interrupt has arrived this specific local interrupt source is disabled The function specific control parameter arg is a pointer to an int value containing the timeout in system ticks To wait indefinitely specify 1 as timeout parameter The delay between an incoming interrupt and the return of the described function is system dependent and is most likely several microseconds For high interrupt load a customized device driver should be used which serves the module specific functionality directly on interrupt level EXAMPLE include tdrv004 h int fd int retval int Timeout Wait at least 5 seconds for incoming interrupt ey Timeout 5 sysClkRateGet retval ioctl fd FIO_TDRV0O04 WAIT _FOR_INT2 int amp Timeout if retval OK acknowledge interrupt source in FPGA logic xij to clear the PLX PCI9030 Local Interrupt Source else handle the error ERROR CODES Error code Description ETIME The interrupt did not arrive before the specified timeout EBUSY There is alre
74. sctdsd aveidiadevssendvavesdiddasssacdsavasdaddanadedvapasliddasuvduideavedaddeatedmndanvela s 54 3 2 16 LOPVOO4 WiiG US Z iiissdistasdeecdsavardisievsresdvaverdatdesarnubdavasdiadsaardudvadvsdaidestvinndsieaddideniodaddanvedaes 57 3 2 17 tdrvO04ConfigurelnterrUpt ceceeeeeceeeeeeeeeeeeeaeeeeaeeseneeecaeeeeaaeeeeaeeseeeeeseaeeeeaeeseeeseaes 60 3 2 18 LAPVOOA W AILFORINT Taiana cavetiadbadeusnvedcstendetiasianeactiaeddavesiaundsieasaans 62 3 2 19 tdrVOO4AWaAitFOrINT 2 einna aaa EE E i aaa iai 64 4 LEGACY VO SYSTEM FUNCTION Swrsivesisschcsccceiiascdecccseanccccsscsieccnsstntecesdanncceausianeces 66 4 1 TAPVOOE DIV oiiaii conten cece ease aka ceeds cases acadcbetadtn as ba vnudwbcduada auvueundencdnnde sGucas sbuucauacesuunwanuuedevncad 66 4 2 TdVOOI DEV ClO at Eoinn aaa aiaa aaaea 68 AS AGrVOOFP CUM se ciscideesctd tute ccsticacstecsuacaacdudaesdnacudesmudesecsudwccauacdewsecautwcuasuccduadcsetwccausncdwsucuedwabausdudutecaddaes 70 AAP TAVOOF Mi a E A E E E E E E 71 5 BASIC 1 0 FUNCTIONS micciscsccecencsicecestcacessccsictcccceacevesasensestesdcanwscdacacieccacedinenscanananece 72 Lota ODOM PAAR E EEE r E A E E 72 5 2 CLOSC eane sen avd sredio a a a e a a A a aaa aai 74 5 3 VOC uen eai aaa aaa aaa a a a ai 76 53 1 FIO TDRVOO4 XSVEPLAY ctmsstsiescsevcianstcoduaiasavsdadsnnadsatonnatdansanaGeiibansdansnsadewadwacvanieaa adtuavende 78 53 2 FIO TDRVO04 XSVEPOS aaea a aaia AEE AEE AEE A Aa aaia 80 5 3 3 FIO_TDRV004_ XSVFLASTCMD
75. stem see VxWorks Reference Manual or a driver set code described below Function specific error codes will be described with the function Error code Description EINVAL The specified Offset Size exceeds the available memory or I O space EACCES The specified Resource is not available for access EBUSY The device is already busy with XSVF Reconfig or SPI action TDRV004 SW 42 VxWorks Device Driver Page 59 of 109 TEWS amp TECHNOLOGIES 3 2 17 tdrv004Configurelnterrupts NAME tdrv004Configurelnterrupts Configure local interrupt source polarity SYNOPSIS STATUS tdrv004SetWaitstates TDRV004_DEV pDev unsigned int InterruptConfig DESCRIPTION This function configures the polarity of the local PLX PCI9030 interrupt sources PARAMETERS pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function InterruptConfig This value is an OR ed value using the following definitions only one value valid for each interrupt source Value Description TDRV004_LINT1_ POLHIGH Local Interrupt Source 1 HIGH active TDRV004_LINT1_ POLLOW Local Interrupt Source 1 LOW active TDRV004_LINT2_POLHIGH Local Interrupt Source 2 HIGH active TDRV004_LINT2_ POLLOW Local Interrupt Source 2 LOW active TDRV004 SW 42 VxWorks Device Driver Page 60 of 109 TENSE TECHNOLOGIES EXAMPLE include tdrv004 h TDRV004_DEV pDev STATUS result u
76. the XSVF data The data must be included inside the TDRV004_XSVF_BUF structure PROGRAMMING HINTS Depending on the XSVF file there might be a waiting period of approx 15 seconds at the beginning of programming The programming of the delivered FPGA example design XSVF file should not take much longer than 1 minute depending on the system load If the programming fails try to increase the used waitstates with control function FIO_TDRV004_SETWAITSTATES refer to the corresponding section in this manual Additionally the CLK1 should not be lower than 10MHz for programming EXAMPLE include tdrv004 h int fd TDRV004_XSVF_BUF oXsvfBuf int bufsize int retval TDRV004 SW 42 VxWorks Device Driver Page 78 of 109 TENSE TECHNOLOGIES allocate enough memory about 3MB to hold XSVF content bufsize sizeof TDRV004_XSVF_BUF lt filesize gt sizeof unsigned char pXsvfBuf TDRVO04_XSVF_BUF malloc bufsize read XSVF content from file and store it inside pXsvfBuf gt pData pXsvfBuf gt pData pxsvfBuf gt size start FPGA programming retval ioctl fd FIO_TDRV004_XSVFPLAY int pXsvfBuf if retval ERROR function succeeded else handle the error free pXsvfBuf ERROR CODES Error code Description EINVAL There was an error during XSVF processing EINTR The function was cancelled EBUSY The device is alrea
77. tion must be included inside the structure PARAMETERS pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function pMemloBuf This parameter specifies a pointer to a TDRV004_MEMIO_BUF structure typedef struct TDRV004 RESOURCE Resource unsigned long Offset unsigned long Size unsigned char pData 1 dynamically expandable TDRV004_MEMIO_BUF Resource Specifies the desired PCI resource to read from The TDRV004_RESOURCE enumeration contains values for all possible memory and I O areas Both first PCI Memory and PCI I O areas of the TDRV004 module are restricted and cannot be used by the application The second found PCl Memory area is named TDRV004_RES_MEM_2 the second PCI I O space found is named TDRVO04_RES_IO 2 and so on The Base Address Register BAR usage is programmable and can be changed by modifying the PLX PCI9030 EEPROM Therefore the following table is just an example how the PCI Base Address Registers could be used TDRV004 SW 42 VxWorks Device Driver Page 45 of 109 BAR PCI Address Type IO reserved MEM reserved used by VHDL Example not implemented by default IO not implemented by default al Ajoin eio O not implemented by default TEWS amp TECHNOLOGIES TDRV004_ RESOURCE TDRV004_RES_IO_1 TDRV004_RES_MEM_1 TDRV004_RES_MEM_2 TDRV004_RES_IO_2 TDRV004_RES_IO_3 TDRV004_RES_MEM_3 The PLX PCI9030
78. to the corresponding open function pClockParam This parameter specifies a pointer to a TDRV004_CLOCK_PARAM structure typedef struct unsigned char DeviceAddr unsigned char x09_CIKOE unsigned char x0C_DIV1SRCN unsigned char x10_InputCtrl unsigned char x40_CPumpPB unsigned char x41_CPumpPB unsigned char x42 _POQcent unsigned char x44 SwMatrix unsigned char x45_SwMatrix unsigned char x46_SwMatrix unsigned char x47_DIV2SRCN TDRV004_CLOCK_PARAM TDRV004 SW 42 VxWorks Device Driver Page 26 of 109 TEWS amp TECHNOLOGIES DeviceAdadr Specifies the desired destination address The CY27EE16 clock generator provides several EEPROM banks as well as SRAM If TDRV004_CLKADR_SRAM 0x69 is specified the values are directly stored inside the volatile RAM area and take effect immediately If TDRV004_CLKADR_EEPROM 0x68 is specified the values are stored in the non volatile area of the clock generator and the CY27EE16 loads it after the next power up X09_CIkOE Specifies which clock outputs shall be enabled x0C_DIV1SRCN Specifies internal input source 1 and the corresponding frequency divider X10_InputCtrl Specifies value for the Input Pin Control register x40_CPumpPB Specifies value for Charge Pump and PB counter register x41_CPumpPB Specifies value for Charge Pump and PB counter register x42_POQent Specifies value for PO and Q counter register X44 SwMatrix Specifies value for Switching Matrix Registe
79. tored in errno and can be read with the function errnoGet Error code Description ENXIO No matching device found EEXIST The device has already been created by a previous call to tdrv004DevCreate S_ioLib NO DRIVER Device driver not installed SEE ALSO VxWorks Programmer s Guide I O System TDRV004 SW 42 VxWorks Device Driver Page 69 of 109 TEWS amp TECHNOLOGIES 4 3 tdrv004Pcilnit NAME tdrv004Pcilnit Generic PCI device initialization SYNOPSIS void tdrv004Pcilnit DESCRIPTION This function is required only for Intel x86 VxWorks platforms The purpose is to setup the MMU mapping for all required TPMC630 family PCI spaces base address register and to enable the TDRV004 device for access The global variable tdrv004Status obtains the result of the device initialization and can be polled later by the application before the driver will be installed Value Meaning gt 0 Initialization successful completed The value of tdrv004Status is equal to the number of mapped PCI spaces 0 No TDRV004 device found lt 0 Initialization failed The value of tdrvO04Status amp OxFF is equal to the number of mapped spaces until the error occurs Possible cause Too few entries for dynamic mappings in sysPhysMemDesc Remedy Add dummy entries as necessary syslib c EXAMPLE extern void tdrv004Pcilnit tdrv004PcilInit TDRV004 SW 42 VxWorks Device Driver Page 70 of 109 TEWS amp TECHNOLOGIE
80. ugh to hold the specified amount of data The data space must be located inside the structure no pointer allowed EXAMPLE include tdrv004 h TDRV004_DEV pDev STATUS result TDRV004_SPI_BUF pSpiBuf int BufferSize TDRV004 SW 42 VxWorks Device Driver Page 34 of 109 TENSE TECHNOLOGIES read 5 bytes from EEPROM block 1 offset 0x00 allocate enough memory to hold the data structure read data wey BufferSize sizeof TDRVO04_SPI_BUF 5 sizeof unsigned char pSpiBuf TDRV004_SPI_BUF malloc BufferSize pSpiBuf gt SpiAddr TDRV004_CLKADDR_EEBLOCK1 pSpiBuf gt SubAddr 0x00 pSpiBuf gt len 57 result tdrv004SpiRead pDev pSpiBuf if result ERROR function succeeded else handle the error free pSpiBuf RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual or a driver set code described below Function specific error codes will be described with the function Error code Description EINVAL The specified SubAddr len exceeds 256 or len is invalid EIO An error occurred during SPI access EBUSY The device is already busy with XSVF Reconfig or SPI action TDRV004 SW 42 VxWorks Device Driver Page 35 of 109 TEWS amp TECHNOL
81. ver Page 9 of 109 TEWS amp TECHNOLOGIES 2 3 3 System Resource Requirement The table gives an overview over the system resources that will be needed by the driver Resource Driver requirement Devices requirement Memory lt 1 KB lt 1 KB Stack lt 1KB Semaphores 3 Memory and Stack usage may differ from system to system depending on the used compiler and its setup The following formula shows the way to calculate the common requirements of the driver and devices lt total requirement gt lt driver requirement gt lt number of devices gt lt device requirement gt The maximum usage of some resources is limited by adjustable parameters If the application and driver exceed these limits increase the according values in your project TDRV004 SW 42 VxWorks Device Driver Page 10 of 109 TEWS amp TECHNOLOGIES 3 API Documentation 3 1 General Functions 3 1 1 tdrv0040Open NAME tdrvO040pen opens a device SYNOPSIS TDRV004_DEV tdrv0040pen char DeviceName DESCRIPTION Before I O can be performed to a device a file descriptor must be opened by a call to this function PARAMETERS DeviceName This parameter points to a null terminated string that specifies the name of the device The first TDRV004 device is named tdrv004 0 the second device is named tdrv004 1 and so on EXAMPLE include tdrv004 h TDRVO004_DEV pDev open f
82. will be described with the function Error code Description EINVAL The specified Offset Size exceeds the available memory or I O space EACCES The specified Resource is not available for access EBUSY The device is already busy with XSVF Reconfig or SPI action TDRV004 SW 42 VxWorks Device Driver Page 47 of 109 TEWS amp TECHNOLOGIES 3 2 13 tdrv004ReadU32 NAME tdrv004ReadU32 Read 32bit values from FPGA resource SYNOPSIS STATUS tdrv004ReadU32 TDRV004_DEV pDev TDRV004_MEMIO_BUF pMemloBuf DESCRIPTION This function reads a number of unsigned long 32bit values from a Memory or I O area by using DWORD 32bit accesses The data buffer can be enlarged to the desired needs The data section must be included inside the structure PARAMETERS pDev This parameter specifies the device descriptor to the hardware module retrieved by a call to the corresponding open function pMemloBuf This parameter specifies a pointer to a TDRV004_MEMIO_BUF structure typedef struct TDRV004 RESOURCE Resource unsigned long Offset unsigned long Size unsigned char pData 1 dynamically expandable TDRV004_MEMIO_BUF Resource Specifies the desired PCI resource to read from The TDRV004_RESOURCE enumeration contains values for all possible memory and I O areas Both first PCI Memory and PCI I O areas of the TDRV004 module are restricted and cannot be used by the application The second found PCl Memory area
83. write data wey BufferSize sizeof TDRV0O04_SPI_BUF 5 sizeof unsigned char pSpiBuf TDRV004_SPI_BUF malloc BufferSize pSpiBuf gt SpiAddr TDRV004_CLKADDR_EEBLOCK1 pSpiBuf gt SubAddr 0x00 pSpiBuf gt len 57 pSpiBuf gt pData 0 0x01 pSpiBuf gt pData 1l 0x02 pSpiBuf gt pData 2 0x03 pSpiBuf gt pData 3 0x04 pSpiBuf gt pData 4 0x05 result tdrv004SpiWrite pDev pSpiBuf if result ERROR function succeeded else handle the error Free pSpiBuf RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual or a driver set code described below Function specific error codes will be described with the function Error code Description EINVAL The specified SubAddr len exceeds 256 or len is invalid EIO An error occurred during SPI access EBUSY The device is already busy with XSVF Reconfig or SPI action TDRV004 SW 42 VxWorks Device Driver Page 32 of 109 TEWS amp TECHNOLOGIES 3 2 8 tdrv004SpiRead NAME tdrv004SpiRead Read values from SPI storage SYNOPSIS STATUS tdrv004SpiRead TDRV004_DEV pDev TDRV004_SPILBUF pSpiloBuf DESCRIPTION This function reads up to 256 unsigned char 8bit values from a specific sub address of a Serial Progr
84. y BARO to BAR2 Offset Specifies the offset into the memory or I O space specified by Resource Size This value specifies the amount of data items to read pData The values are copied from this buffer It must be large enough to hold the specified amount of data EXAMPLE in clude tdrv004 h TDRV004_DEV pDev STATUS result TDRVO04_MEMIO_BUF pMemIoBuf unsigned char pValues int BufferSize kx k Buf pMe pMe pMe pMe pVa pVa pVa TDRV004 write 10 byte to MemorySpace 2 offset 0x00 allocate enough memory to hold the data structure write data ferSize sizeof TDRVO04_MEMIO_BUF 10 sizeof unsigned char mIoBuf TDRV004_MEMIO_BUF malloc BufferSize mIoBuf gt Size 10 mIoBuf gt Resource TDRV004_RES_MEM_2 mloBuf gt Offset 0 lues unsigned char pMemloBuf gt pData lues 0 0x01 lues 1 0x02 SW 42 VxWorks Device Driver Page 52 of 109 TEWS amp TECHNOLOGIES result tdrv004WriteUs pDev pMemIoBuf if retval ERROR function succeeded else handle the error fFree pMemIoBuf RETURN VALUE OK if function succeeds or ERROR ERROR CODES The error codes are stored in errno and can be read with the function errnoGet The error code is a standard error code set by the I O system see VxWorks Reference Manual or a driver set code described below Function specific error
85. y area is named TDRV004_RES_MEM_2 the second PCI I O space found is named TDRV004_RES_IO_2 and so on The Base Address Register BAR usage is programmable and can be changed by modifying the PLX PCI9030 EEPROM Therefore the following table is just an example how the PCI Base Address Registers could be used TDRV004 SW 42 VxWorks Device Driver Page 54 of 109 TENSE TECHNOLOGIES BAR PCI Address Type TDRV004_RESOURCE 0 IO reserved TDRV004_RES_ IO_1 1 MEM reserved TDRV004_ RES_MEM_1 2 MEM used by VHDL Example TDRV004_RES_MEM_2 3 IO not implemented by default TDRV004_RES_IO_2 4 IO not implemented by default TDRV004_RES_IO 3 5 MEM notimplemented by default TDRV004_RES_MEM_3 The PLX PCI9030 default configuration utilizes only BARO to BAR2 Offset Specifies the offset into the memory or I O space specified by Resource Size This value specifies the amount of data items to read pData The values are copied from this buffer It must be large enough to hold the specified amount of data EXAMPLE in clude tdrv004 h TDRV004_DEV pDev STATUS result TDRVO04_MEMIO_BUF pMemIoBuf unsigned short pValues int BufferSize kx k Buf pMe pMe pMe pMe pVa pVa pVa TDRV004 write 10 16bit words to MemorySpace 2 offset 0x00 allocate enough memory to hold the data structure write data ferSize sizeof TDRVO04_MEMIO_BUF 10 sizeof unsigned short

Download Pdf Manuals

image

Related Search

Related Contents

De invitado en Alemania.    7 - Gartentechnik.com  8-PORT 10/100MBPS PoE ETHERNET SWITCH Manual  40, 46 & 55-inch wuxga narrow bezel tft-lcd  Manual de acceso rápido: “BIBLIO”  IP.TV HD Help  BenQ FP785 User's Manual  GE Profile JMP31 Electric Kitchen Range  die Betriebsanleitung finden Sie hier  

Copyright © All rights reserved.
Failed to retrieve file