mbgtools-lx
4.2.8
|
#include <pcpsdrvr.h>
#include <identdec.h>
#include <mbgddmsg.h>
#include <plxdefs.h>
#include <pci_asic.h>
#include <amccdefs.h>
#include <pcidefs.h>
#include <pci.h>
Go to the source code of this file.
Macros | |
#define | _PCPSDRVR |
#define | REPORT_CFG 10 |
#define | REPORT_CFG_DETAILS 1 |
#define | REPORT_CFG_LOG_LVL MBG_LOG_INFO |
#define | TEST_CFG_DETAILS 0 |
#define | USE_CMD_PTR 1 |
#define | DEBUG_ACCESS_TIMING 0 |
#define | DEBUG_IO_TIMING 0 |
#define | DEBUG_IO 1 |
#define | DEBUG_PORTS 1 |
#define | DEBUG_SERNUM 1 |
#define | USE_USB_MICRO_FRAMES 0 |
#define | TEST_PORT_ACCESS 0 |
#define | MUST_REPORT_PROBE_DEVICE_DETAILS 1 |
#define | MUST_REPORT_ACCESS_MODE 1 |
#define | PCPS_LOG_STD_MSGS 0 |
#define | _do_div(_x, _y) do { _x /= _y; } while ( 0 ) |
#define | MAX_BOOT_TIME_PTP270PEX 27 |
Max. time required for PTP270PEX v1 card to be ready after power-up. More... | |
#define | _fmemcpy(_d, _s, _n) memcpy( _d, _s, _n ) |
#define | _fstrlen(_s) strlen( _s ) |
#define | _fstrncmp(_s1, _s2, _n) strncmp( (_s1), (_s2), (_n) ) |
#define | static_wc |
#define | FMT_03X "%03X" |
#define | FMT_08X "%08lX" |
#define | _pcps_irq_flags unsigned long irq_flags; |
#define | _pcps_disb_local_irq_save() local_irq_save( irq_flags ) |
#define | _pcps_local_irq_restore() local_irq_restore( irq_flags ) |
#define | _pcps_time_after(_curr, _tmo) ( _curr >= _tmo ) |
#define | MBG_TGT_HAS_UPTIME 1 |
#define | FP_FMT "%p" |
Typedefs | |
typedef unsigned int | PCI_DWORD |
Functions | |
static __mbg_inline int | pcps_ddev_is_ptp270pex (const PCPS_DDEV *pddev) |
Check if a device is a PTP270PEX card. More... | |
static int | mbg_plx_read_pecs_reg (struct pci_dev *pNode, uint16_t reg, uint32_t *pval) |
Read a dword from a PLX PECS register. More... | |
static bool | ptp270pex_can_flag_ready (const PCPS_DDEV *pddev) |
Check if a PTP270PEX card can indicate when it's ready. More... | |
static bool | ptp270pex_has_flagged_ready (const PCPS_DDEV *pddev) |
Check if a PTP270PEX card indicates it is ready. More... | |
static void | report_uptime (const MBG_SYS_UPTIME *p_uptime) |
Report the system uptime. More... | |
static void | wait_ptp270pex_ready (const PCPS_DDEV *pddev) |
Wait until a PTP270PEX card is ready after power-up. More... | |
static bool | pcps_check_pex_irq_unsafe (PCPS_DDEV *pddev, uint16_t req_fw_ver, uint8_t req_asic_ver_major, uint8_t req_asic_ver_minor) |
Check if IRQ usage with a device is unsafe. More... | |
static int | setup_mm_addr (PCPS_DDEV *pddev) |
Setup the memory mapped addresses depending on the device type. More... | |
void | pcps_dump_data (const void *buffer, size_t count, const char *info) |
static void | report_io_cmd (uint8_t cmd, uint16_t count, const char *info) |
static void | report_ret_val (int rc, const char *info) |
Report the return code to be returned by a function. More... | |
__mbg_inline int | pcps_wait_busy (PCPS_DDEV *pddev) |
Wait as long as a device is busy, or until timeout. More... | |
static int | pcps_read_null (PCPS_DDEV *pddev, uint8_t cmd, void FAR *buffer, uint16_t count) |
Dummy read function. More... | |
static int | pcps_read_std (PCPS_DDEV *pddev, uint8_t cmd, void FAR *buffer, uint16_t count) |
Read function for devices with ISA or micro channel bus. More... | |
static int | pcps_read_amcc_s5933 (PCPS_DDEV *pddev, uint8_t cmd, void FAR *buffer, uint16_t count) |
Read function for devices with AMCC S5933 PCI interface chip. More... | |
static int | pcps_read_amcc_s5920 (PCPS_DDEV *pddev, uint8_t cmd, void FAR *buffer, uint16_t count) |
Read function for devices with AMCC S5920 PCI interface chip. More... | |
static int | pcps_read_asic (PCPS_DDEV *pddev, uint8_t cmd, void FAR *buffer, uint16_t count) |
Read function for devices with Meinberg PCI interface ASIC. More... | |
int | pcps_write (PCPS_DDEV *pddev, uint8_t cmd, const void FAR *buffer, uint16_t count) |
Write data to a device. More... | |
int | pcps_generic_io (PCPS_DDEV *pddev, uint8_t type, const void FAR *in_buff, uint8_t in_cnt, void FAR *out_buff, uint8_t out_cnt) |
Generic I/O function. More... | |
static int | pcps_check_gps_data_size (PCPS_DDEV *pddev, uint16_t count, const char *info) |
Determine which interface buffer size is supported. More... | |
static int | pcps_init_gps_transfer (PCPS_DDEV *pddev, uint8_t cmd, uint8_t data_type, uint16_t count, const char *info) |
Initialize GPS data transfer. More... | |
static int | pcps_read_gps_block (PCPS_DDEV *pddev, uint8_t data_type, void FAR *buffer, uint16_t count, uint8_t block_num, uint8_t block_size) |
Get a block of data from a GPS device. More... | |
int | pcps_read_gps (PCPS_DDEV *pddev, uint8_t data_type, void FAR *buffer, uint16_t count) |
Read a large data structure from a device. More... | |
int | pcps_write_gps (PCPS_DDEV *pddev, uint8_t data_type, const void FAR *buffer, uint16_t count) |
Write a large data structure to a device. More... | |
static int | pcps_get_fw_id (PCPS_DDEV *pddev, PCPS_ID_STR FAR fw_id) |
Read the firmware ID from a device. More... | |
static int | pcps_check_id (PCPS_DDEV *pddev, const char FAR *ref) |
Check an ASCIIZ string for a valid signature. More... | |
static PCPS_FW_REV_NUM | pcps_get_rev_num (char FAR *idstr) |
Retrieve a version number from a firmware ID string. More... | |
static bool | str_remove_unprintables (char *s, size_t max_len) |
Remove unprintable characters from a string. More... | |
static void | beautify_sernum (char *s, size_t max_len) |
static void | check_unknown_sernum (char *s, size_t max_len) |
static const char * | get_bus_type_str (const PCPS_DDEV *pddev) |
static void | report_probe_device (const PCPS_DDEV *pddev) |
static const char * | get_pcps_feature_name (PCPS_FEATURES flag_mask) |
Get the name assigned to one of the PCPS_FEATURE_MASKS flags. More... | |
static void | dump_receiver_info (const PCPS_DDEV *pddev) |
static void | dump_xfeature_buffer (const PCPS_DDEV *pddev) |
static void | dump_tlv_info (const PCPS_DDEV *pddev) |
static void | check_feature (PCPS_DDEV *pddev, ushort req_rev_num, PCPS_FEATURES flag_mask) |
Check the firmware to see if a specific feature is supported. More... | |
static void | check_ri_features (PCPS_DDEV *pddev) |
Check the receiver info features to see if a specific feature is supported. More... | |
int | setup_sernum_and_receiver_info (PCPS_DDEV *pddev) |
Read the serial number and receiver info from the device. More... | |
void | check_receiver_info_and_features (PCPS_DDEV *pddev) |
Check the receiver info and features. More... | |
void | pcps_release_rsrcs (PCPS_DDEV *pddev) |
Release I/O port and memory resource that have been claimed before. More... | |
PCPS_DEV_TYPE * | pcps_get_dev_type_table_entry (PCPS_BUS_FLAGS bus_mask, PCPS_DEV_ID dev_id) |
Lookup a specific device in the device table. More... | |
static void | pcps_free_ddev_struc (PCPS_DDEV **ppddev) |
Free a previously allocated device info structure. More... | |
static int | pcps_alloc_ddev_struc (PCPS_DDEV **ppddev) |
Allocate a device info structure for a device. More... | |
int | pcps_init_ddev (PCPS_DDEV **ppddev) |
Allocate and initialize a device info structure. More... | |
void | pcps_cleanup_ddev (PCPS_DDEV *pddev) |
Clean up and free a previously initialized device info structure. More... | |
static void | rsrc_port_to_cfg_port (PCPS_SHORT_PORT_RSRC *p_short_port_rsrc, const MBG_IOPORT_RSRC *p_io_rsrc) |
Convert a raw I/O base address to a short format. More... | |
int | pcps_add_rsrc_io (PCPS_DDEV *pddev, MBG_IOPORT_ADDR_RAW base, ulong num) |
Add an I/O address range resource to the device structure. More... | |
int | pcps_add_rsrc_mem (PCPS_DDEV *pddev, MBG_IOMEM_ADDR_RAW start, ulong len) |
Add a memory address range resource to the device structure. More... | |
int | pcps_add_rsrc_irq (PCPS_DDEV *pddev, int16_t irq_num) |
Add an IRQ number resource to the device structure. More... | |
int | pcps_chk_dev_feat (PCPS_DDEV *p_ddev, uint feat_type, uint feat_num) |
Check if a specific feature of a specific feature type is supported. More... | |
static void | set_access_mode (PCPS_DDEV *pddev, uint mode, bool forced, PCPS_READ_FNC *read_fnc) |
static void | report_access_mode (const PCPS_DDEV *pddev) |
int | pcps_probe_device (PCPS_DDEV *pddev, PCPS_BUS_NUM bus_num, PCPS_SLOT_NUM dev_fnc_num) |
Probe if a device is supported, and allocate and setup the device structure. More... | |
void | pcps_cleanup_device (PCPS_DDEV *pddev) |
Clean up function called by pcps_probe_device on error. More... | |
void | pcps_detect_isa_devices (PCPS_DDEV_INIT_FNC *ddev_init_fnc, PCPS_DDEV_CLEANUP_FNC *ddev_cleanup_fnc, PCPS_DDEV_REGISTER_FNC *ddev_register_fnc, int isa_ports[PCPS_MAX_ISA_CARDS], int isa_irqs[PCPS_MAX_ISA_CARDS]) |
Detect and initialize ISA devices in a non-PnP system. More... | |
static void _MBG_INIT_CODE_ATTR | pcps_detect_devices_init (PCPS_DDEV_INIT_FNC *ddev_init_fnc, PCPS_DDEV_CLEANUP_FNC *ddev_cleanup_fnc, int isa_ports[PCPS_MAX_ISA_CARDS], int isa_irqs[PCPS_MAX_ISA_CARDS]) |
_PCPS_USE_ISA_PNP More... | |
void _MBG_INIT_CODE_ATTR | pcps_detect_devices (int isa_ports[PCPS_MAX_ISA_CARDS], int isa_irqs[PCPS_MAX_ISA_CARDS]) |
Detect all bus-level devices in a non-PnP system. More... | |
#define _do_div | ( | _x, | |
_y | |||
) | do { _x /= _y; } while ( 0 ) |
Definition at line 516 of file pcpsdrvr.c.
Referenced by report_io_cmd().
#define _fmemcpy | ( | _d, | |
_s, | |||
_n | |||
) | memcpy( _d, _s, _n ) |
Definition at line 558 of file pcpsdrvr.c.
Referenced by pcps_generic_io().
#define _fstrlen | ( | _s | ) | strlen( _s ) |
Definition at line 559 of file pcpsdrvr.c.
Referenced by pcps_check_id(), and pcps_get_rev_num().
#define _fstrncmp | ( | _s1, | |
_s2, | |||
_n | |||
) | strncmp( (_s1), (_s2), (_n) ) |
Definition at line 560 of file pcpsdrvr.c.
Referenced by pcps_check_id().
#define _pcps_disb_local_irq_save | ( | ) | local_irq_save( irq_flags ) |
Definition at line 589 of file pcpsdrvr.c.
Referenced by pcps_read_amcc_s5920(), pcps_read_amcc_s5933(), pcps_read_asic(), and pcps_read_std().
#define _pcps_irq_flags unsigned long irq_flags; |
Definition at line 586 of file pcpsdrvr.c.
Referenced by pcps_read_amcc_s5920(), pcps_read_amcc_s5933(), pcps_read_asic(), and pcps_read_std().
#define _pcps_local_irq_restore | ( | ) | local_irq_restore( irq_flags ) |
Definition at line 592 of file pcpsdrvr.c.
Referenced by pcps_read_amcc_s5920(), pcps_read_amcc_s5933(), pcps_read_asic(), and pcps_read_std().
#define _pcps_time_after | ( | _curr, | |
_tmo | |||
) | ( _curr >= _tmo ) |
Definition at line 625 of file pcpsdrvr.c.
Referenced by pcps_wait_busy().
#define _PCPSDRVR |
Definition at line 362 of file pcpsdrvr.c.
#define DEBUG_ACCESS_TIMING 0 |
Definition at line 438 of file pcpsdrvr.c.
#define DEBUG_IO 1 |
Definition at line 454 of file pcpsdrvr.c.
#define DEBUG_IO_TIMING 0 |
Definition at line 447 of file pcpsdrvr.c.
#define DEBUG_PORTS 1 |
Definition at line 462 of file pcpsdrvr.c.
#define DEBUG_SERNUM 1 |
Definition at line 470 of file pcpsdrvr.c.
#define FMT_03X "%03X" |
Definition at line 573 of file pcpsdrvr.c.
Referenced by pcps_detect_isa_devices().
#define FMT_08X "%08lX" |
Definition at line 574 of file pcpsdrvr.c.
Referenced by pcps_cleanup_device(), and pcps_detect_isa_devices().
#define FP_FMT "%p" |
Referenced by pcps_generic_io().
#define MAX_BOOT_TIME_PTP270PEX 27 |
Max. time required for PTP270PEX v1 card to be ready after power-up.
The PTP270PEX cards have an on-board Linux system which must have finished booting before the card can be accessed via the PCI bus. If the card is accessed earlier then the PCI bus and thus the computer may hang.
There are 2 different hardware versions of the PTP270PEX card. PTP270PEX v2 hardware and firmware can flag via a bit in the PCI configuration space when the card is ready, so the driver can just wait until the card has flagged that it's ready.
However, the PTP270PEX v1 hardware doesn't support this, so the driver checks the system uptime and waits until it is greater or equal the maximum time required for a PTP270PEX v1 card to finish booting.
The nominal time is 27 s, but if a firmware update has been submitted then the update is applied first, which takes another few seconds.
Definition at line 543 of file pcpsdrvr.c.
Referenced by report_uptime(), and wait_ptp270pex_ready().
#define MBG_TGT_HAS_UPTIME 1 |
Definition at line 638 of file pcpsdrvr.c.
#define MUST_REPORT_ACCESS_MODE 1 |
Definition at line 495 of file pcpsdrvr.c.
#define MUST_REPORT_PROBE_DEVICE_DETAILS 1 |
Definition at line 489 of file pcpsdrvr.c.
#define PCPS_LOG_STD_MSGS 0 |
Definition at line 504 of file pcpsdrvr.c.
#define REPORT_CFG 10 |
Definition at line 409 of file pcpsdrvr.c.
#define REPORT_CFG_DETAILS 1 |
Definition at line 417 of file pcpsdrvr.c.
#define REPORT_CFG_LOG_LVL MBG_LOG_INFO |
Definition at line 423 of file pcpsdrvr.c.
Referenced by check_feature(), check_receiver_info_and_features(), check_ri_features(), dump_receiver_info(), dump_tlv_info(), dump_xfeature_buffer(), and setup_sernum_and_receiver_info().
#define static_wc |
Definition at line 572 of file pcpsdrvr.c.
Referenced by pcps_release_rsrcs().
#define TEST_CFG_DETAILS 0 |
Definition at line 426 of file pcpsdrvr.c.
#define TEST_PORT_ACCESS 0 |
Definition at line 484 of file pcpsdrvr.c.
#define USE_CMD_PTR 1 |
Definition at line 430 of file pcpsdrvr.c.
#define USE_USB_MICRO_FRAMES 0 |
Definition at line 477 of file pcpsdrvr.c.
typedef unsigned int PCI_DWORD |
Definition at line 578 of file pcpsdrvr.c.
|
static |
Definition at line 3749 of file pcpsdrvr.c.
References _pcps_ddev_sernum, and str_remove_unprintables().
Referenced by setup_sernum_and_receiver_info().
|
static |
Check the firmware to see if a specific feature is supported.
Some devices provide a specific feature only starting with a specific firmware version, but the device provides no way to test this, so the feature flag in the device structure is set if the firmware has the required version.
[in,out] | pddev | Pointer to the device structure |
[in] | req_rev_num | Revision number required for the feature to be supported |
[in] | flag_mask | Flag mask of the feature to be tested |
Definition at line 4001 of file pcpsdrvr.c.
References _mbg_kdd_msg_5, _pcps_ddev_fw_rev_num, _pcps_ddev_type_name, PCPS_DEV::cfg, PCPS_DDEV_s::dev, PCPS_DEV_CFG::features, get_pcps_feature_name(), REPORT_CFG_LOG_LVL, and str_empty.
Referenced by pcps_probe_device().
void check_receiver_info_and_features | ( | PCPS_DDEV * | pddev | ) |
Check the receiver info and features.
[in,out] | pddev | Pointer to a device structure |
Definition at line 4274 of file pcpsdrvr.c.
Referenced by pcps_probe_device().
|
static |
Check the receiver info features to see if a specific feature is supported.
Some devices provide a RECEIVER_INFO which provides some flags that can be mapped to the feature flags we use internally, so we scan these features and update the internal features mask accordingly.
[in,out] | pddev | Pointer to the device structure |
Definition at line 4031 of file pcpsdrvr.c.
References _mbg_kdd_msg_3, _mbg_kdd_msg_4, _pcps_ddev_fw_rev_num, _pcps_ddev_type_name, _ri_addr, PCPS_DEV::cfg, PCPS_DDEV_s::dev, PCPS_DEV_CFG::features, RECEIVER_INFO::features, gps_ri_feature_names, N_GPS_FEATURE, pcps_feature_names, REPORT_CFG_LOG_LVL, and ri_feat_tbl.
Referenced by check_receiver_info_and_features().
|
static |
Definition at line 3792 of file pcpsdrvr.c.
Referenced by setup_sernum_and_receiver_info().
|
static |
Definition at line 3891 of file pcpsdrvr.c.
References _mbg_kdd_msg_1, _mbg_kdd_msg_2, _ri_addr, SW_REV::code, RECEIVER_INFO::epld_name, RECEIVER_INFO::features, RECEIVER_INFO::fixed_freq, RECEIVER_INFO::flags, FIXED_FREQ_INFO::khz_val, RECEIVER_INFO::model_code, RECEIVER_INFO::model_name, RECEIVER_INFO::n_channels, RECEIVER_INFO::n_com_ports, RECEIVER_INFO::n_prg_out, RECEIVER_INFO::n_str_type, RECEIVER_INFO::n_ucaps, SW_REV::name, RECEIVER_INFO::osc_flags, RECEIVER_INFO::osc_type, FIXED_FREQ_INFO::range, REPORT_CFG_LOG_LVL, RECEIVER_INFO::sernum, RECEIVER_INFO::sw_rev, and RECEIVER_INFO::ticks_per_sec.
Referenced by check_receiver_info_and_features().
|
static |
Definition at line 3965 of file pcpsdrvr.c.
References _mbg_kdd_msg_1, _mbg_kdd_msg_2, _tlv_info_addr, MBG_TLV_FEAT_BUFFER::b, check_feat_supp_byte_array(), MBG_TLV_INFO::flags, MAX_MBG_TLV_FEAT_TYPES, MBG_LOG_WARN, mbg_rc_is_success, MBG_TLV_FEAT_TYPE_NAMES, N_MBG_TLV_FEAT_TYPES, REPORT_CFG_LOG_LVL, MBG_TLV_INFO::reserved, str_unkn_braced, and MBG_TLV_INFO::supp_tlv_feat.
Referenced by check_receiver_info_and_features().
|
static |
Definition at line 3947 of file pcpsdrvr.c.
References _mbg_kdd_msg_2, _xfeat_addr, MBG_XFEATURE_BUFFER::b, check_feat_supp_byte_array(), MAX_XFEATURE_BITS, MBG_LOG_WARN, mbg_rc_is_success, MBG_XFEATURE_NAMES, N_MBG_XFEATURE, REPORT_CFG_LOG_LVL, and str_unkn_braced.
Referenced by check_receiver_info_and_features().
|
static |
Definition at line 3812 of file pcpsdrvr.c.
References _pcps_ddev_bus_flags, PCPS_BUS_ISA, PCPS_BUS_MCA, PCPS_BUS_PCI_ASIC, PCPS_BUS_PCI_MBGPEX, PCPS_BUS_PCI_PEX8311, PCPS_BUS_PCI_S5920, PCPS_BUS_PCI_S5933, PCPS_BUS_USB, PCPS_BUS_USB_V2, and str_unkn_braced.
Referenced by report_probe_device().
|
static |
Get the name assigned to one of the PCPS_FEATURE_MASKS flags.
[in] | flag_mask | one of the PCPS_FEATURE_MASKS flags |
Definition at line 3872 of file pcpsdrvr.c.
References N_PCPS_FEATURE_BITS, pcps_feature_names, and str_unkn_braced.
Referenced by check_feature().
|
static |
Read a dword from a PLX PECS register.
[in] | pNode | Device structure |
[in] | reg | Number of the register to read |
[out] | pval | Pointer to a variable to take the value read from the register |
Definition at line 804 of file pcpsdrvr.c.
References PCI_BAD_REGISTER_NUMB, PCI_SUCCESS, PLX_PECS_MAINDATA, and PLX_PECS_MAININDEX.
Referenced by ptp270pex_can_flag_ready().
int pcps_add_rsrc_io | ( | PCPS_DDEV * | pddev, |
MBG_IOPORT_ADDR_RAW | base, | ||
ulong | num | ||
) |
Add an I/O address range resource to the device structure.
[in,out] | pddev | Pointer to the device structure |
[in] | base | Base address of the I/O address range |
[in] | num | Number of addresses of the I/O address range |
Definition at line 4897 of file pcpsdrvr.c.
Referenced by pcps_cleanup_device(), pcps_detect_isa_devices(), and pcps_release_rsrcs().
Add an IRQ number resource to the device structure.
[in,out] | pddev | Pointer to the device structure |
[in] | irq_num | Start address of the memory range |
Definition at line 5021 of file pcpsdrvr.c.
Referenced by pcps_cleanup_device(), and pcps_detect_isa_devices().
int pcps_add_rsrc_mem | ( | PCPS_DDEV * | pddev, |
MBG_IOMEM_ADDR_RAW | start, | ||
ulong | len | ||
) |
Add a memory address range resource to the device structure.
[in,out] | pddev | Pointer to the device structure |
[in] | start | Start address of the memory range |
[in] | len | Size of the memory range |
Definition at line 4959 of file pcpsdrvr.c.
Referenced by pcps_cleanup_device().
|
static |
Allocate a device info structure for a device.
On success, the pointer to the device structure is set to the allocated memory for the device structure.
[in,out] | ppddev | Address of a pointer to a device structure to be allocated |
Definition at line 4744 of file pcpsdrvr.c.
References _mbgddmsg_0, _mbgddmsg_fnc_entry, _mbgddmsg_fnc_exit_chk_mbg_rc, _pcps_kmalloc, DEBUG_DEV_INIT, MBG_ERR_NO_MEM, MBG_LOG_ERR, MBG_SUCCESS, n_ddevs, N_SUPP_DEV_BUS, and pcps_ddev.
Referenced by pcps_init_ddev().
Determine which interface buffer size is supported.
[in] | pddev | Pointer to the device structure |
[in] | count | The number of bytes to be read according to the data_type |
[in] | info | An info string, e.g. the name of the calling function |
Definition at line 3170 of file pcpsdrvr.c.
References _mbg_kdd_msg_1, _pcps_ddev_has_gps_data_16, MBG_ERR_NBYTES, MBG_LOG_ERR, MBG_SUCCESS, and PCPS_DDEV_s::size_n_bytes.
Referenced by pcps_read_gps_block(), and pcps_write_gps().
Check an ASCIIZ string for a valid signature.
This function is only used to determine the type of a legacy ISA card. For PCI and USB devices the type can be determined from the device ID.
[in] | pddev | Pointer to a device structure |
[in] | ref | The reference signature, i.e. the expected signature at the beginning of the device's firmware ID |
Definition at line 3648 of file pcpsdrvr.c.
References _fstrlen, _fstrncmp, _pcps_ddev_fw_id, MBG_ERR_FW_ID, and MBG_SUCCESS.
Referenced by pcps_probe_device().
|
static |
Check if IRQ usage with a device is unsafe.
A few early PCI Express cards had a problem where usage of IRQs was unsafe. Firmware upgrades are available to fix this. See http://www.meinberg.de/english/info/pex-upgrades.htm
[in] | pddev | Pointer to the device structure |
[in] | req_fw_ver | Required firmware version |
[in] | req_asic_ver_major | Required ASIC major version |
[in] | req_asic_ver_minor | Required ASIC major version |
Definition at line 1152 of file pcpsdrvr.c.
References _pcps_ddev_asic_version, _pcps_ddev_fw_rev_num, _pcps_pex_irq_is_safe, PCPS_DDEV_s::irq_ack_mask, PCPS_DDEV_s::irq_ack_port, PCPS_DDEV_s::irq_stat_info, and PCPS_IRQ_STAT_UNSAFE.
Referenced by pcps_probe_device().
Check if a specific feature of a specific feature type is supported.
There are different structures where information can be stored if a specific feature is supported. All information is set up when the pcps_probe_device function is called to probe and initialize the device. This generic low-level function can be called by API functions to check if a specific feature is supported.
[in] | p_ddev | Pointer to the device structure |
[in] | feat_type | See DEV_FEAT_TYPES |
[in] | feat_num | Number and range depending on feat_type value |
Definition at line 5112 of file pcpsdrvr.c.
Referenced by check_receiver_info_and_features(), do_chk_dev_feat(), and ioctl_switch().
void pcps_cleanup_ddev | ( | PCPS_DDEV * | pddev | ) |
Clean up and free a previously initialized device info structure.
[in] | pddev | Address of a device structure to be cleaned up and released |
Definition at line 4845 of file pcpsdrvr.c.
Referenced by mbgclock_init_module(), and pcps_detect_devices().
void pcps_cleanup_device | ( | PCPS_DDEV * | pddev | ) |
Clean up function called by pcps_probe_device on error.
[in,out] | pddev | Pointer to the device structure |
Definition at line 6247 of file pcpsdrvr.c.
Referenced by pcps_probe_device().
|
static |
Check if a device is a PTP270PEX card.
Definition at line 782 of file pcpsdrvr.c.
References _pcps_ddev_dev_id, _pcps_ddev_is_pci, and PCI_DEV_PTP270PEX.
Referenced by pcps_probe_device().
void _MBG_INIT_CODE_ATTR pcps_detect_devices | ( | int | isa_ports[PCPS_MAX_ISA_CARDS], |
int | isa_irqs[PCPS_MAX_ISA_CARDS] | ||
) |
Detect all bus-level devices in a non-PnP system.
[in] | isa_ports | An array with potential I/O base addresses for ISA devices. |
[in] | isa_irqs | An array with potential IRQ numbers assigned to ISA devices. |
Definition at line 6683 of file pcpsdrvr.c.
References pcps_cleanup_ddev(), pcps_detect_devices_init(), and pcps_init_ddev().
Referenced by mbg_find_devices(), and mbgclock_init_module().
|
static |
_PCPS_USE_ISA_PNP
Detect all bus-level devices in a non-PnP system, use specific alloc/cleanup functions
[in] | ddev_init_fnc | Pointer to function called to allocate a device structure for each detected device. |
[in] | ddev_cleanup_fnc | Pointer to function called if the device structure needs to be de-allocated in case of error. |
[in] | isa_ports | An array with potential I/O base addresses for ISA devices. |
[in] | isa_irqs | An array with potential IRQ numbers assigned to ISA devices. |
Definition at line 6647 of file pcpsdrvr.c.
References N_PCPS_DEV_TYPE, PCI_VENDOR_MEINBERG, pcps_detect_isa_devices(), pcps_detect_pci_devices(), and pcps_dev_type.
Referenced by pcps_detect_devices().
void pcps_detect_isa_devices | ( | PCPS_DDEV_INIT_FNC * | ddev_init_fnc, |
PCPS_DDEV_CLEANUP_FNC * | ddev_cleanup_fnc, | ||
PCPS_DDEV_REGISTER_FNC * | ddev_register_fnc, | ||
int | isa_ports[PCPS_MAX_ISA_CARDS], | ||
int | isa_irqs[PCPS_MAX_ISA_CARDS] | ||
) |
Detect and initialize ISA devices in a non-PnP system.
[in] | ddev_init_fnc | Pointer to function called to allocate a device structure for each detected device. |
[in] | ddev_cleanup_fnc | Pointer to function called if the device structure needs to be de-allocated in case of error. |
[in] | ddev_register_fnc | Pointer to function called to register a detected device. |
[in] | isa_ports | An array with potential I/O base addresses for ISA devices. |
[in] | isa_irqs | An array with potential IRQ numbers assigned to ISA devices. |
Definition at line 6559 of file pcpsdrvr.c.
References _mbgddmsg_1, _mbgddmsg_2, PCPS_DEV_TYPE::bus_flags, PCPS_DEV::cfg, DEBUG_DEV_INIT, PCPS_DDEV_s::dev, PCPS_DEV_CFG::err_flags, FMT_03X, FMT_08X, MBG_LOG_INFO, MBG_LOG_WARN, mbg_rc_is_success, pcps_add_rsrc_io(), pcps_add_rsrc_irq(), PCPS_BUS_ISA, PCPS_MAX_ISA_CARDS, PCPS_NUM_PORTS_ISA, pcps_probe_device(), and PCPS_DEV::type.
Referenced by mbgclock_init_module(), and pcps_detect_devices_init().
void pcps_dump_data | ( | const void * | buffer, |
size_t | count, | ||
const char * | info | ||
) |
Definition at line 1219 of file pcpsdrvr.c.
Referenced by pcps_read_amcc_s5920(), pcps_read_amcc_s5933(), pcps_read_asic(), pcps_read_std(), and report_ret_val().
|
static |
Free a previously allocated device info structure.
The pointer to the device structure is set to NULL after the associated memory has been freed.
[in,out] | ppddev | Address of a pointer to a device structure to be freed |
Definition at line 4704 of file pcpsdrvr.c.
References _mbgddmsg_fnc_entry, _mbgddmsg_fnc_exit, _pcps_kfree, and n_ddevs.
Referenced by pcps_cleanup_ddev().
PCPS_DEV_TYPE* pcps_get_dev_type_table_entry | ( | PCPS_BUS_FLAGS | bus_mask, |
PCPS_DEV_ID | dev_id | ||
) |
Lookup a specific device in the device table.
The function below takes a bus flag and device ID to search the table of known devices for a device which matches the given criteria.
[in] | bus_mask | Mask of the bus type to look up, see PCPS_BUS_FLAG_MASKS |
[in] | dev_id | The device ID to lookup, see MEINBERG_PCI_DEVICE_IDS or MBG_USB_DEVICE_IDS, depending on the bus_mask |
Definition at line 4672 of file pcpsdrvr.c.
Referenced by pcps_add_rsrc_irq().
|
static |
Read the firmware ID from a device.
This is usually done first when probing a device to check if the device is properly installed and can be accessed without problems.
[in] | pddev | Pointer to a device structure |
[out] | fw_id | A buffer to be filled withtthe firmware ID |
Definition at line 3591 of file pcpsdrvr.c.
References _mbgddmsg_1, _mbgddmsg_2, _pcps_ddev_type_name, _pcps_read, DEBUG_DEV_INIT, PCPS_IO_BUFFER::fw_id, PCPS_DDEV_s::io_buffer, MBG_LOG_INFO, mbg_rc_is_error, PCPS_FIFO_SIZE, PCPS_GIVE_FW_ID_1, PCPS_GIVE_FW_ID_2, and PCPS_ID_SIZE.
Referenced by pcps_probe_device().
|
static |
Retrieve a version number from a firmware ID string.
[in] | idstr | The ID string, e.g. a PCPS_ID_STR |
Definition at line 3671 of file pcpsdrvr.c.
References _fstrlen.
Referenced by pcps_probe_device().
int pcps_init_ddev | ( | PCPS_DDEV ** | ppddev | ) |
Allocate and initialize a device info structure.
On success, the pointer to the device structure is set to the device structure, and the device structure has been initialized.
[in,out] | ppddev | Address of a pointer to a device structure to be allocated and initialized |
Definition at line 4799 of file pcpsdrvr.c.
Referenced by mbgclock_init_module(), and pcps_detect_devices().
|
static |
Initialize GPS data transfer.
[in] | pddev | Pointer to the device structure |
[in] | cmd | PCPS_READ_GPS_DATA or PCPS_WRITE_GPS_DATA |
[in] | data_type | The code assigned to the data type, see PC_GPS_CMD_CODES |
[in] | count | The number of bytes to be read according to the data_type |
[in] | info | An info string, e.g. the name of the calling function |
Definition at line 3215 of file pcpsdrvr.c.
References _mbg16_to_cpu, _mbg_kdd_msg_1, _mbg_kdd_msg_2, _mbg_kdd_msg_3, _pcps_read, _pcps_read_var, MBG_ERR_INV_TYPE, MBG_ERR_NBYTES, MBG_ERR_NOT_READY, MBG_LOG_DEBUG, MBG_LOG_ERR, MBG_LOG_WARN, mbg_rc_is_error, PCPS_DDEV_s::n_bytes, PCPS_DDEV_s::size_n_bytes, and PCPS_DDEV_s::uc.
Referenced by pcps_read_gps_block(), and pcps_write_gps().
int pcps_probe_device | ( | PCPS_DDEV * | pddev, |
PCPS_BUS_NUM | bus_num, | ||
PCPS_SLOT_NUM | dev_fnc_num | ||
) |
Probe if a device is supported, and allocate and setup the device structure.
This function should be called by the probe routine of any target-specific kernel driver. If the device is supported then all specific information including supported features is read from the device and stored in sub-structures of the device structure addressed by pdev.
[in,out] | pddev | Pointer to the device structure which has been initialized and will be set up |
[in] | bus_num | The bus number if supported (e.g. PCI), else 0 |
[in] | dev_fnc_num | The device/function number if supported (e.g. PCI), else 0 |
Definition at line 5409 of file pcpsdrvr.c.
Referenced by pcps_cleanup_device(), pcps_detect_isa_devices(), and pcps_release_rsrcs().
|
static |
Get a block of data from a GPS device.
This static function is used by pcps_read_gps.
[in] | pddev | Pointer to the device structure |
[in] | data_type | The code assigned to the data type, see PC_GPS_CMD_CODES |
[out] | buffer | A buffer with data to be read according to the data_type |
[in] | count | The number of bytes to be read according to the data_type |
[in] | block_num | A buffer with data to be written according to the type code |
[in] | block_size | The number of bytes to be written according to the type code |
Definition at line 3342 of file pcpsdrvr.c.
References _mbg_kdd_msg_4, _pcps_read, MBG_LOG_DEBUG, mbg_rc_is_error, pcps_check_gps_data_size(), pcps_init_gps_transfer(), PCPS_READ_GPS_DATA, report_ret_val(), and PCPS_DDEV_s::size_n_bytes.
Referenced by pcps_read_gps().
void pcps_release_rsrcs | ( | PCPS_DDEV * | pddev | ) |
Release I/O port and memory resource that have been claimed before.
[in,out] | pddev | The device structure |
Definition at line 4411 of file pcpsdrvr.c.
Referenced by pcps_cleanup_device().
__mbg_inline int pcps_wait_busy | ( | PCPS_DDEV * | pddev | ) |
Wait as long as a device is busy, or until timeout.
Used by the Device read functions to wait after the command byte has been written until the requested data has been made available by the device.
[in] | pddev | Pointer to the device structure |
Definition at line 1981 of file pcpsdrvr.c.
References _pcps_ddev_status_busy, _pcps_ddev_timeout_clk, _pcps_time_after, clock, MBG_ERR_TIMEOUT, and MBG_SUCCESS.
Referenced by pcps_read_amcc_s5920(), pcps_read_amcc_s5933(), pcps_read_asic(), pcps_read_std(), and report_ret_val().
Check if a PTP270PEX card can indicate when it's ready.
A PTP270PEX card must be accessed by the driver only after it has finished booting. Otherwise the host system may be locked up.
On HW v2 cards the firmware can indicate when the card is ready to be accessed, so this can be checked by the driver. On these cards the on-board GPIO3 pin is hardwired to 0 to indicate this is supported, whereas on older v1 cards the GPIO3 pin is pulled up to 1.
[in] | pddev | Pointer to the device structure |
Definition at line 869 of file pcpsdrvr.c.
References _mbg_kdd_msg_1, _mbg_kdd_msg_3, _pcps_ddev_type_name, PCPS_DEV_CFG::bus_num, PCPS_DEV::cfg, PCPS_DDEV_s::dev, MBG_LOG_DEBUG, mbg_plx_read_pecs_reg(), PCI_DEVICE_ID_PLX_8111, PCI_SUCCESS, PLX_PECS_GPIOCTL, and PLX_PECS_GPIOCTL_GPIO3_DATA.
Referenced by wait_ptp270pex_ready().
Check if a PTP270PEX card indicates it is ready.
A PTP270PEX card must be accessed by the driver only after it has finished booting. Otherwise the host system may be locked up.
On HW v2 cards the firmware can indicate when the card is ready to be accessed, so the driver can call this function to check this.
[in] | pddev | Pointer to the device structure |
Definition at line 979 of file pcpsdrvr.c.
References _mbg_inp32_to_cpu, _pcps_ddev_io_base_mapped, PLX_LCS_CNTRL, and PLX_LCS_CNTRL_USERI.
Referenced by wait_ptp270pex_ready().
|
static |
Definition at line 5313 of file pcpsdrvr.c.
References _mbg_kdd_msg_1, _mbg_kdd_msg_2, _mbg_kdd_msg_3, _pcps_ddev_fw_has_20ms_bug, _pcps_ddev_fw_id, _pcps_ddev_fw_rev_num, _pcps_ddev_io_base_raw, _pcps_ddev_irq_num, _pcps_ddev_sernum, _pcps_ddev_type_name, _pcps_fw_rev_num_major, _pcps_fw_rev_num_minor, PCPS_DDEV_s::access_mode, PCPS_DDEV_s::access_mode_forced, mbg_kdd_snprintf(), MBG_LOG_INFO, MBG_LOG_WARN, N_PCPS_ACCESS_MODES, PCPS_RSRC_INFO::num_rsrc_irq, PCPS_ACCESS_MODE_STR_FRCD, PCPS_ACCESS_MODE_STRS, PCPS_FW_STR_FMT, PCPS_DDEV_s::rsrc_info, and str_unkn_braced.
Referenced by pcps_probe_device().
Definition at line 1266 of file pcpsdrvr.c.
References _cpu_to_mbg32, _do_div, _mbg_inp32_to_cpu, _mbg_inp8, _mbg_kdd_msg_0, _mbg_kdd_msg_1, _mbg_kdd_msg_3, _mbg_kdd_msg_4, _mbg_kdd_msg_5, _mbg_kdd_msg_7, _pcps_ddev_is_pci_s5920, _pcps_ddev_is_usb, _pcps_ddev_type_name, PCPS_DDEV_s::acc_cycles, PCI_ASIC_REG::b, mbg_get_pc_cycles(), MBG_LOG_DEBUG, MBG_LOG_INFO, PCPS_DDEV_s::mm_asic_addr, pc_cycles_frequency, PCI_ASIC::pci_data, PCI_ASIC::status_port, PCPS_DDEV_s::status_port, PCI_ASIC_REG::ul, and PCI_ASIC_REG::us.
Referenced by pcps_read_amcc_s5920(), pcps_read_amcc_s5933(), pcps_read_asic(), and pcps_read_std().
|
static |
Definition at line 3836 of file pcpsdrvr.c.
References _mbg_kdd_msg_4, _pcps_ddev_bus_num, _pcps_ddev_dev_id, _pcps_ddev_is_pci, _pcps_ddev_pci_fnc_num, _pcps_ddev_pci_slot_num, _pcps_ddev_slot_num, _pcps_ddev_type_name, get_bus_type_str(), mbg_kdd_snprintf(), and MBG_LOG_INFO.
Referenced by pcps_probe_device().
|
static |
Report the return code to be returned by a function.
[in] | rc | The return code to be reported |
[in] | info | Informational string to be printed |
Definition at line 1536 of file pcpsdrvr.c.
References _mbg_kdd_msg_0, _mbg_kdd_msg_1, _mbg_kdd_msg_2, _mbg_kdd_msg_3, _mbg_kdd_msg_4, _mbgddmsg_1, _mbgddmsg_3, _pcps_ddev_has_hr_time, _pcps_ddev_set_err_flags, _pcps_kfree, _pcps_kmalloc, _pcps_read_var, PCPS_DDEV_s::acc_cycles, PCPS_DDEV_s::cmd, PCPS_DDEV_s::cmd_info, FAR, PCPS_DDEV_s::gps_cmd_info, PCPS_DDEV_s::io_buffer, mbg_delta_pc_cycles(), MBG_ERR_NBYTES, MBG_ERR_NO_MEM, mbg_get_pc_cycles(), MBG_LOG_DEBUG, MBG_LOG_ERR, MBG_LOG_INFO, mbg_rc_is_error, mbg_strerror(), MBG_SUCCESS, pc_cycles_frequency, pcps_dump_data(), PCPS_EF_IO_INIT, PCPS_GIVE_HR_TIME, PCPS_IO_BUFFER::pcps_hr_time, PCPS_READ_GPS_DATA, pcps_wait_busy(), PCPS_WRITE_GPS_DATA, str_empty, and str_spc_gps.
Referenced by pcps_generic_io(), pcps_read_amcc_s5920(), pcps_read_amcc_s5933(), pcps_read_asic(), pcps_read_gps(), pcps_read_gps_block(), pcps_read_std(), pcps_write(), and pcps_write_gps().
|
static |
Report the system uptime.
This is mainly used for debugging, and informational.
[in] | p_uptime | The system uptime |
Definition at line 1011 of file pcpsdrvr.c.
References _mbg_kdd_msg_1, _mbg_kdd_msg_2, MAX_BOOT_TIME_PTP270PEX, and MBG_LOG_INFO.
Referenced by wait_ptp270pex_ready().
|
static |
Convert a raw I/O base address to a short format.
See notes for PCPS_SHORT_PORT_RSRC.
[out] | p_short_port_rsrc | Pointer to a variable that takes up the converted address |
[in] | p_io_rsrc | Pointer to a variable with the address to be converted |
Definition at line 4878 of file pcpsdrvr.c.
References PCPS_SHORT_PORT_RSRC::base, MBG_IOPORT_RSRC::base_raw, MBG_IOPORT_RSRC::num, and PCPS_SHORT_PORT_RSRC::num.
Referenced by pcps_probe_device().
|
static |
Definition at line 5302 of file pcpsdrvr.c.
References PCPS_DDEV_s::access_mode, PCPS_DDEV_s::access_mode_forced, and PCPS_DDEV_s::read.
Referenced by pcps_cleanup_device(), and pcps_probe_device().
|
static |
Setup the memory mapped addresses depending on the device type.
[in] | pddev | Pointer to the device structure |
Definition at line 1183 of file pcpsdrvr.c.
References _mbg_kdd_msg_1, _pcps_ddev_is_pci_mbgpex, _pcps_ddev_is_pci_pex8311, FAR, MBG_LOG_INFO, MBG_SUCCESS, PCPS_RSRC_INFO::mem, PCPS_DDEV_s::mm_asic_addr, PCPS_DDEV_s::mm_tstamp_addr, PCPS_DDEV_s::rsrc_info, and MBG_IOMEM_RSRC::start_mapped.
Referenced by pcps_probe_device().
int setup_sernum_and_receiver_info | ( | PCPS_DDEV * | pddev | ) |
Read the serial number and receiver info from the device.
The retrieved information is stored in the associated fields of the sub-structures of pddev.
[in,out] | pddev | Pointer to a device structure |
Definition at line 4097 of file pcpsdrvr.c.
Referenced by pcps_probe_device().
|
static |
Remove unprintable characters from a string.
[in,out] | s | Pointer to the string. |
[in] | max_len | Size of the string buffer. |
Definition at line 3716 of file pcpsdrvr.c.
Referenced by beautify_sernum().
|
static |
Wait until a PTP270PEX card is ready after power-up.
A PTP270PEX card must be accessed by the driver only after it has finished booting. Otherwise the host system may be locked up.
[in] | pddev | Pointer to the device structure |
Definition at line 1065 of file pcpsdrvr.c.
References _mbg_kdd_msg_2, MAX_BOOT_TIME_PTP270PEX, mbg_delta_sys_time_ms(), mbg_get_sys_time(), mbg_get_sys_uptime(), MBG_LOG_INFO, mbg_sleep_sec(), ptp270pex_can_flag_ready(), ptp270pex_has_flagged_ready(), and report_uptime().
Referenced by pcps_probe_device().
|
static |
A table of name strings associated with GPS_FEATURE_BITS.
Definition at line 733 of file pcpsdrvr.c.
Referenced by check_ri_features().
|
static |
Clock frequency of the PC's cycles counter, in [Hz].
An attempt to determine this value is made at the beginning of the pcps_probe_device routine. If the cycles frequency value is 0 then the target system doesn't supported this, or the value couldn't be determined. In this case it's not possible to convert a number of cycles to an associatred time interval.
Definition at line 661 of file pcpsdrvr.c.
Referenced by pcps_probe_device(), report_io_cmd(), and report_ret_val().
|
static |
A table of name strings associated with PCPS_FEATURE_BITS.
Definition at line 744 of file pcpsdrvr.c.
Referenced by check_ri_features(), and get_pcps_feature_name().
|
static |
A table used to map RECEIVER_INFO::features to PCPS_DEV_CFG::features.
The enumerated GPS_FEATURE_BITS can be used as index to this table, and the table entry contains a combination of associated PCPS_FEATURE_MASKS, if there are any.
Definition at line 688 of file pcpsdrvr.c.
Referenced by check_ri_features().
|
static |
Definition at line 642 of file pcpsdrvr.c.
Referenced by check_feature(), pcps_probe_device(), and report_ret_val().
|
static |
Definition at line 646 of file pcpsdrvr.c.
Referenced by report_ret_val().
|
static |
Definition at line 643 of file pcpsdrvr.c.
Referenced by dump_tlv_info(), dump_xfeature_buffer(), get_bus_type_str(), get_pcps_feature_name(), and report_access_mode().