285 #if !defined( USE_LOCAL_IO_BUFFER ) 286 #define USE_LOCAL_IO_BUFFER 0 289 #if defined( MBG_TGT_NETWARE ) 290 #define _DEFAULT_PCPS_USE_CLOCK_TICK 1 291 #define _DEFAULT_PCPS_USE_ISA 1 292 #define _DEFAULT_PCPS_USE_MCA 0 293 #define _DEFAULT_PCPS_USE_PCI 1 294 #define _DEFAULT_PCPS_USE_ISA_PNP 0 295 #define _DEFAULT_PCPS_USE_PCI_PNP 0 296 #define _DEFAULT_PCPS_USE_USB 0 297 #define _DEFAULT_PCPS_USE_RSRCMGR 0 298 #elif defined( MBG_TGT_OS2 ) 299 #define _DEFAULT_PCPS_USE_CLOCK_TICK 0 300 #define _DEFAULT_PCPS_USE_ISA 1 301 #define _DEFAULT_PCPS_USE_MCA 0 302 #define _DEFAULT_PCPS_USE_PCI 1 303 #define _DEFAULT_PCPS_USE_ISA_PNP 0 304 #define _DEFAULT_PCPS_USE_PCI_PNP 0 305 #define _DEFAULT_PCPS_USE_USB 0 306 #define _DEFAULT_PCPS_USE_RSRCMGR 1 307 #elif defined( MBG_TGT_WIN32_PNP ) 308 #define _DEFAULT_PCPS_USE_CLOCK_TICK 1 309 #define _DEFAULT_PCPS_USE_ISA 1 310 #define _DEFAULT_PCPS_USE_MCA 0 311 #define _DEFAULT_PCPS_USE_PCI 1 312 #define _DEFAULT_PCPS_USE_ISA_PNP 1 313 #define _DEFAULT_PCPS_USE_PCI_PNP 1 314 #define _DEFAULT_PCPS_USE_USB 1 315 #define _DEFAULT_PCPS_USE_RSRCMGR 0 316 #elif defined( MBG_TGT_WIN32 ) 317 #define _DEFAULT_PCPS_USE_CLOCK_TICK 1 318 #define _DEFAULT_PCPS_USE_ISA 1 319 #define _DEFAULT_PCPS_USE_MCA 0 320 #define _DEFAULT_PCPS_USE_PCI 1 321 #define _DEFAULT_PCPS_USE_ISA_PNP 0 322 #define _DEFAULT_PCPS_USE_PCI_PNP 0 323 #define _DEFAULT_PCPS_USE_USB 0 324 #define _DEFAULT_PCPS_USE_RSRCMGR 0 325 #elif defined( MBG_TGT_LINUX ) 327 #define _DEFAULT_PCPS_USE_CLOCK_TICK 1 328 #define _DEFAULT_PCPS_USE_ISA defined( MBG_ARCH_X86 ) 329 #define _DEFAULT_PCPS_USE_MCA 0 330 #define _DEFAULT_PCPS_USE_PCI 1 331 #define _DEFAULT_PCPS_USE_ISA_PNP 0 332 #define _DEFAULT_PCPS_USE_PCI_PNP _DEFAULT_MBG_TGT_LINUX_USE_PCI_PNP 333 #define _DEFAULT_PCPS_USE_USB _DEFAULT_MBG_TGT_LINUX_USE_USB 334 #define _DEFAULT_PCPS_USE_RSRCMGR 1 335 #elif defined( MBG_TGT_BSD ) //##++ 336 #define _DEFAULT_PCPS_USE_CLOCK_TICK 1 337 #define _DEFAULT_PCPS_USE_ISA 1 338 #define _DEFAULT_PCPS_USE_MCA 0 339 #define _DEFAULT_PCPS_USE_PCI 1 340 #define _DEFAULT_PCPS_USE_ISA_PNP 0 341 #define _DEFAULT_PCPS_USE_PCI_PNP 1 342 #define _DEFAULT_PCPS_USE_USB 0 343 #define _DEFAULT_PCPS_USE_RSRCMGR 1 344 #elif defined( MBG_TGT_QNX ) 345 #define _DEFAULT_PCPS_USE_CLOCK_TICK 1 346 #define _DEFAULT_PCPS_USE_ISA 1 347 #define _DEFAULT_PCPS_USE_MCA 0 348 #define _DEFAULT_PCPS_USE_PCI 1 349 #define _DEFAULT_PCPS_USE_ISA_PNP 0 350 #define _DEFAULT_PCPS_USE_PCI_PNP 0 351 #define _DEFAULT_PCPS_USE_USB 0 352 #define _DEFAULT_PCPS_USE_RSRCMGR 0 354 #define _DEFAULT_PCPS_USE_CLOCK_TICK 1 355 #define _DEFAULT_PCPS_USE_ISA 1 356 #define _DEFAULT_PCPS_USE_MCA 0 357 #define _DEFAULT_PCPS_USE_PCI 1 358 #define _DEFAULT_PCPS_USE_PCI_PNP 0 359 #define _DEFAULT_PCPS_USE_ISA_PNP 0 360 #define _DEFAULT_PCPS_USE_USB 0 361 #define _DEFAULT_PCPS_USE_RSRCMGR 0 364 #ifndef _PCPS_USE_CLOCK_TICK 365 #define _PCPS_USE_CLOCK_TICK _DEFAULT_PCPS_USE_CLOCK_TICK 368 #ifndef _PCPS_USE_ISA 369 #define _PCPS_USE_ISA _DEFAULT_PCPS_USE_ISA 372 #ifndef _PCPS_USE_MCA 373 #define _PCPS_USE_MCA _DEFAULT_PCPS_USE_MCA 376 #ifndef _PCPS_USE_PCI 377 #define _PCPS_USE_PCI _DEFAULT_PCPS_USE_PCI 380 #ifndef _PCPS_USE_ISA_PNP 381 #define _PCPS_USE_ISA_PNP _DEFAULT_PCPS_USE_ISA_PNP 384 #ifndef _PCPS_USE_PCI_PNP 385 #define _PCPS_USE_PCI_PNP _DEFAULT_PCPS_USE_PCI_PNP 388 #ifndef _PCPS_USE_USB 389 #define _PCPS_USE_USB _DEFAULT_PCPS_USE_USB 392 #ifndef _PCPS_USE_RSRCMGR 393 #define _PCPS_USE_RSRCMGR _DEFAULT_PCPS_USE_RSRCMGR 397 #ifndef _PCPS_USE_PCI_BIOS 398 #define _PCPS_USE_PCI_BIOS ( _PCPS_USE_PCI && !_PCPS_USE_PCI_PNP ) 401 #define _PCPS_USE_PNP ( _PCPS_USE_PCI_PNP || _PCPS_USE_ISA_PNP || _PCPS_USE_USB ) 403 #if _PCPS_USE_PCI_PNP && _PCPS_USE_PCI_BIOS 404 #error "PCI PNP and non-PNP can't be used at the same time" 408 #if !defined( _MBG_INIT_CODE_ATTR ) 410 #define _MBG_INIT_CODE_ATTR 413 #if !defined( DEBUG_DRVR ) 417 #if !defined( DEBUG_DEV_INIT ) 418 #define DEBUG_DEV_INIT 0 421 #if !defined( DEBUG_USB_IO ) 422 #define DEBUG_USB_IO 0 425 #if !defined( DEBUG_IOCTL ) 426 #define DEBUG_IOCTL 0 439 #if defined( MBG_TGT_FREEBSD ) 440 #include <sys/malloc.h> 441 #include <sys/_null.h> 442 #include <sys/param.h> 443 #include <sys/lock.h> 444 #include <machine/bus.h> 445 #elif defined( MBG_TGT_NETBSD ) 446 #include <sys/kmem.h> 451 #if defined( MBG_TGT_DOS ) 456 #if defined( MBG_TGT_WIN32 ) 458 #include <mbgnames.h> 461 #if defined( MBG_TGT_LINUX ) 462 #include <linux/slab.h> 463 #include <linux/mm.h> 466 #include <linux/usb.h> 470 #if defined( MBG_TGT_QNX ) 476 #if defined( MBG_TGT_NETWARE ) 482 #if defined( MBG_TGT_OS2 ) 484 #define INCL_DOSSEMAPHORES 495 #if _PCPS_USE_RSRCMGR 505 #if defined( MBG_TGT_NETBSD ) && defined( MBG_DEBUG ) 507 #define DEBUG MBG_DEBUG 528 #if !defined( MBG_DRVR_NAME ) 529 #if defined( MBG_TGT_WIN32 ) 530 #define MBG_DRVR_NAME MBG_SVC_NAME_MBGCLOCK 532 #define MBG_DRVR_NAME "mbgclock" 543 #define _DEFAULT_PCPS_USE_MM_IO ( MBG_TGT_SUPP_MEM_ACC && !MBG_USE_MM_IO_FOR_PCI ) 545 #if !defined( _PCPS_USE_MM_IO ) 546 #define _PCPS_USE_MM_IO _DEFAULT_PCPS_USE_MM_IO 553 #if defined( MBG_TGT_LINUX ) 555 #define _pcps_kmalloc( _sz ) kmalloc( _sz, GFP_ATOMIC ) 556 #define _pcps_kfree( _p, _sz ) kfree( _p ) 563 #define _pcps_sem_inc( _pddev ) \ 567 if ( _mbg_mutex_acquire( &(_pddev)->dev_mutex ) < 0 ) \ 568 return -ERESTARTSYS; \ 570 spin_lock_irqsave( &(_pddev)->irq_lock, flags ); \ 571 atomic_inc( &(_pddev)->access_in_progress ); \ 572 spin_unlock_irqrestore( &(_pddev)->irq_lock, flags ); \ 575 #define _pcps_sem_dec( _pddev ) \ 576 atomic_dec( &(_pddev)->access_in_progress ); \ 577 _mbg_mutex_release( &(_pddev)->dev_mutex ) 579 #elif defined( MBG_TGT_FREEBSD ) 585 MALLOC_DECLARE( M_MBGCLOCK );
586 #define _pcps_kmalloc( _sz ) malloc( _sz, M_MBGCLOCK, M_NOWAIT | M_ZERO ) 587 #define _pcps_kfree( _p, _sv ) free( _p, M_MBGCLOCK ) 589 #elif defined( MBG_TGT_NETBSD ) 593 #define _pcps_kmalloc( _sz ) kmem_alloc( _sz, KM_NOSLEEP ) 594 #define _pcps_kfree( _p, _sz ) kmem_free( _p, _sz ) 596 #elif defined( MBG_TGT_WIN32 ) 598 #define _pcps_kmalloc( _sz ) ExAllocatePool( NonPagedPool, _sz ) 599 #define _pcps_kfree( _p, _sz ) ExFreePool( _p ) 601 #elif defined( MBG_TGT_DOS ) 606 #define _pcps_sem_inc( _pddev ) \ 609 #define _pcps_sem_dec( _pddev ) \ 615 #if !defined( _PCPS_STATIC_DEV_LIST ) 620 #define _PCPS_STATIC_DEV_LIST ( !_PCPS_USE_PNP ) 627 #if !defined( _pcps_sem_inc ) || !defined( _pcps_sem_dec ) 629 #define _pcps_sem_inc( _pddev ) \ 630 _mbg_mutex_acquire( &(_pddev)->dev_mutex ) 632 #define _pcps_sem_dec( _pddev ) \ 633 _mbg_mutex_release( &(_pddev)->dev_mutex ) 641 #if !defined( PCPS_TIMEOUT_CNT ) 642 #if _PCPS_USE_CLOCK_TICK 643 #if defined( MBG_TGT_NETWARE ) 644 #define PCPS_TIMEOUT_CNT ( (ulong)( 200 * __get_CLK_TCK() ) / 1000 ) 645 #elif defined( MBG_TGT_LINUX ) 646 #define PCPS_TIMEOUT_CNT ( (ulong)( 200 * HZ ) / 1000 ) 647 #elif defined( MBG_TGT_BSD ) 648 #define PCPS_TIMEOUT_CNT ( (ulong)( 200 ) ) // [ms] 649 #elif defined( MBG_TGT_WIN32 ) 650 #define PCPS_TIMEOUT_CNT ( (ulong)( 200 * MBG_TICKS_PER_SEC ) / 1000 ) 651 #elif defined( MBG_TGT_QNX_NTO ) 652 #define PCPS_TIMEOUT_CNT ( (ulong)( 200 * CLOCKS_PER_SEC ) / 1000 ) 654 #define PCPS_TIMEOUT_CNT ( (ulong)( 200 * CLK_TCK ) / 1000 ) 657 #define PCPS_TIMEOUT_CNT 0x7FFFFFUL 666 #define N_PCPS_MEM_RSRC 2 672 #define MAX_PCPS_RSRC ( N_PCPS_MEM_RSRC + N_PCPS_PORT_RSRC ) 709 return ( ep & 0x80 ) != 0;
715 #if defined( MBG_TGT_LINUX ) 719 #if _PCPS_USE_LINUX_KTHREAD 722 typedef struct task_struct *PCPS_THREAD_INFO;
731 struct completion exit;
735 #endif // _PCPS_USE_LINUX_KTHREAD 737 #endif // defined( MBG_TGT_LINUX ) 739 #endif // _PCPS_USE_USB 801 #if defined( _MBG_MUTEX_DEFINED ) 813 #if defined( _MBG_SPINLOCK_DEFINED ) 814 MBG_SPINLOCK tstamp_lock;
815 MBG_SPINLOCK irq_lock;
854 #if !USE_LOCAL_IO_BUFFER 858 #if defined( MBG_TGT_WIN32 ) 862 #if defined( MBG_TGT_LINUX ) 871 wait_queue_head_t wait_queue;
882 struct usb_device *udev;
883 struct usb_interface *intf;
884 PCPS_THREAD_INFO usb_read_thread;
885 struct semaphore sem_usb_cyclic;
890 #if defined( MBG_TGT_BSD ) 895 #if _PCPS_USE_RSRCMGR 896 #if defined( MBG_TGT_OS2 ) 929 #define PCPS_ACCESS_MODE_STRS \ 931 "No real port I/O (dummy fnc)", \ 933 "Standard port I/O", \ 934 "Memory mapped I/O", \ 935 "16 bit memory mapped I/O" \ 943 #define PCPS_ACCESS_MODE_STR_FRCD " (forced)" 950 #define PCPS_DECODE_WIDTH_PCI 16 961 #define MCA_ID_PS31 0x6AAC 962 #define MCA_ID_PS31_OLD 0x6303 967 #define PCPS_NUM_PORTS_MCA 16 972 #define PCPS_DECODE_WIDTH_MCA 16 985 #define ISA_ID_PCPS MCA_ID_PS31 994 #define PCPS_DEFAULT_PORT 0x0300 1000 #define PCPS_NUM_PORTS_ISA 4 1006 #define PCPS_DECODE_WIDTH_ISA 10 1011 #if defined( DEBUG ) 1070 #if !defined( PCPS_MAX_ISA_CARDS ) 1071 #define PCPS_MAX_ISA_CARDS N_SUPP_DEV_BUS // the number of ISA cards supported 1076 #if _PCPS_STATIC_DEV_LIST 1081 #if defined( MBG_TGT_DOS ) || defined( MBG_TGT_NETWARE ) //##++ 1082 _ext int curr_ddev_num;
1116 #define fw_id_ref_pcps fw_id_ref[0] 1117 #define fw_id_ref_gps fw_id_ref[2] 1130 #define _pcps_ddev_type_num( _p ) _pcps_type_num( &(_p)->dev ) 1131 #define _pcps_ddev_type_name( _p ) _pcps_type_name( &(_p)->dev ) 1132 #define _pcps_ddev_dev_id( _p ) _pcps_dev_id( &(_p)->dev ) 1133 #define _pcps_ddev_ref_type( _p ) _pcps_ref_type( &(_p)->dev ) 1134 #define _pcps_ddev_bus_flags( _p ) _pcps_bus_flags( &(_p)->dev ) 1138 #define _pcps_ddev_is_gps( _p ) _pcps_is_gps( &(_p)->dev ) 1139 #define _pcps_ddev_is_dcf( _p ) _pcps_is_dcf( &(_p)->dev ) 1140 #define _pcps_ddev_is_msf( _p ) _pcps_is_msf( &(_p)->dev ) 1141 #define _pcps_ddev_is_wwvb( _p ) _pcps_is_wwvb( &(_p)->dev ) 1142 #define _pcps_ddev_is_irig_rx( _p ) _pcps_is_irig_rx( &(_p)->dev ) 1143 #define _pcps_ddev_is_ptp( _p ) _pcps_is_ptp( &(_p)->dev ) 1144 #define _pcps_ddev_is_frc( _p ) _pcps_is_frc( &(_p)->dev ) 1146 #define _pcps_ddev_is_lwr( _p ) _pcps_is_lwr( &(_p)->dev ) 1147 #define _pcps_ddev_is_gnss( _p ) _pcps_is_gnss( &(_p)->dev ) 1151 #define _pcps_ddev_is_isa( _p ) _pcps_is_isa( &(_p)->dev ) 1152 #define _pcps_ddev_is_mca( _p ) _pcps_is_mca( &(_p)->dev ) 1153 #define _pcps_ddev_is_pci( _p ) _pcps_is_pci( &(_p)->dev ) 1154 #define _pcps_ddev_is_usb( _p ) _pcps_is_usb( &(_p)->dev ) 1157 #define _pcps_ddev_is_usb_v2( _p ) _pcps_is_usb_v2( &(_p)->dev ) 1158 #define _pcps_ddev_is_pci_s5933( _p ) _pcps_is_pci_s5933( &(_p)->dev ) 1159 #define _pcps_ddev_is_pci_s5920( _p ) _pcps_is_pci_s5920( &(_p)->dev ) 1160 #define _pcps_ddev_is_pci_amcc( _p ) _pcps_is_pci_amcc( &(_p)->dev ) 1161 #define _pcps_ddev_is_pci_asic( _p ) _pcps_is_pci_asic( &(_p)->dev ) 1162 #define _pcps_ddev_is_pci_pex8311( _p ) _pcps_is_pci_pex8311( &(_p)->dev ) 1163 #define _pcps_ddev_is_pci_mbgpex( _p ) _pcps_is_pci_mbgpex( &(_p)->dev ) 1167 #define _pcps_ddev_bus_num( _p ) _pcps_bus_num( &(_p)->dev ) 1168 #define _pcps_ddev_slot_num( _p ) _pcps_slot_num( &(_p)->dev ) 1169 #define _pcps_ddev_pci_slot_num( _p ) ( _pcps_ddev_slot_num( _p ) >> 3 ) 1170 #define _pcps_ddev_pci_fnc_num( _p ) ( _pcps_ddev_slot_num( _p ) & 0x07 ) 1172 #define _pcps_ddev_short_port_rsrc( _p, _n ) _pcps_short_port_rsrc( &(_p)->dev, _n ) 1173 #define _pcps_ddev_short_port_base( _p, _n ) _pcps_short_port_base( &(_p)->dev, _n ) 1175 #define _pcps_ddev_io_rsrc( _p, _n ) ( (_p)->rsrc_info.port[_n] ) 1176 #define _pcps_ddev_io_base_raw( _p, _n ) ( _pcps_ddev_io_rsrc( _p, _n ).base_raw ) 1177 #define _pcps_ddev_io_base_mapped( _p, _n ) ( _pcps_ddev_io_rsrc( _p, _n ).base_mapped ) 1178 #define _pcps_ddev_irq_num( _p ) _pcps_irq_num( &(_p)->dev ) 1179 #define _pcps_ddev_timeout_clk( _p ) _pcps_timeout_clk( &(_p)->dev ) 1181 #define _pcps_ddev_mem_rsrc( _p, _n ) ( (_p)->rsrc_info.mem[_n] ) 1183 #define _pcps_ddev_fw_rev_num( _p ) _pcps_fw_rev_num( &(_p)->dev ) 1184 #define _pcps_ddev_features( _p ) _pcps_features( &(_p)->dev ) 1185 #define _pcps_ddev_fw_id( _p ) _pcps_fw_id( &(_p)->dev ) 1186 #define _pcps_ddev_sernum( _p ) _pcps_sernum( &(_p)->dev ) 1187 #define _pcps_ddev_sernum_size( _p ) sizeof( (_p)->dev.cfg.sernum ) 1189 #define _pcps_ddev_raw_asic_version( _p ) ( (_p)->raw_asic_version ) 1190 #define _pcps_ddev_asic_version( _p ) ( (_p)->asic_version ) 1193 #define _pcps_ddev_err_flags( _p ) \ 1194 _pcps_err_flags( &(_p)->dev ) 1196 #define _pcps_ddev_chk_err_flags( _p, _msk ) \ 1197 _pcps_chk_err_flags( &(_p)->dev, _msk ) 1199 #define _pcps_ddev_set_err_flags( _p, _msk ) \ 1200 _pcps_set_err_flags( &(_p)->dev, _msk ) 1202 #define _pcps_ddev_clr_err_flags( _p, _msk ) \ 1203 _pcps_clr_err_flags( &(_p)->dev, _msk ) 1210 #define _pcps_ddev_access_mode_io( _p ) \ 1211 ( (_p)->access_mode == PCPS_ACC_MODE_IO ) 1213 #define _pcps_ddev_access_mode_mm( _p ) \ 1214 ( ( (_p)->access_mode == PCPS_ACC_MODE_MM ) || \ 1215 ( (_p)->access_mode == PCPS_ACC_MODE_MM16 ) ) 1220 #define _pcps_ddev_can_set_time( _p ) _pcps_can_set_time( &(_p)->dev ) 1221 #define _pcps_ddev_has_serial( _p ) _pcps_has_serial( &(_p)->dev ) 1222 #define _pcps_ddev_has_sync_time( _p ) _pcps_has_sync_time( &(_p)->dev ) 1223 #define _pcps_ddev_has_ident( _p ) _pcps_has_ident( &(_p)->dev ) 1224 #define _pcps_ddev_has_utc_offs( _p ) _pcps_has_utc_offs( &(_p)->dev ) 1225 #define _pcps_ddev_has_hr_time( _p ) _pcps_has_hr_time( &(_p)->dev ) 1226 #define _pcps_ddev_has_sernum( _p ) _pcps_has_sernum( &(_p)->dev ) 1227 #define _pcps_ddev_has_cab_len( _p ) _pcps_has_cab_len( &(_p)->dev ) 1228 #define _pcps_ddev_has_tzdl( _p ) _pcps_has_tzdl( &(_p)->dev ) 1229 #define _pcps_ddev_has_pcps_tzdl( _p ) _pcps_has_pcps_tzdl( &(_p)->dev ) 1230 #define _pcps_ddev_has_tzcode( _p ) _pcps_has_tzcode( &(_p)->dev ) 1231 #define _pcps_ddev_has_tz( _p ) _pcps_has_tz( &(_p)->dev ) 1233 #define _pcps_ddev_has_event_time( _p ) _pcps_has_event_time( &(_p)->dev ) 1234 #define _pcps_ddev_has_receiver_info( _p ) _pcps_has_receiver_info( &(_p)->dev ) 1235 #define _pcps_ddev_can_clr_ucap_buff( _p ) _pcps_can_clr_ucap_buff( &(_p)->dev ) 1236 #define _pcps_ddev_has_ucap( _p ) _pcps_has_ucap( &(_p)->dev ) 1237 #define _pcps_ddev_has_irig_tx( _p ) _pcps_has_irig_tx( &(_p)->dev ) 1241 #define _pcps_ddev_has_serial_hs( _p ) \ 1242 _pcps_has_serial_hs( &(_p)->dev ) 1245 #define _pcps_ddev_has_signal( _p ) \ 1246 _pcps_has_signal( &(_p)->dev ) 1248 #define _pcps_ddev_has_mod( _p ) \ 1249 _pcps_has_mod( &(_p)->dev ) 1251 #define _pcps_ddev_has_irig( _p ) \ 1252 _pcps_has_irig( &(_p)->dev ) 1254 #define _pcps_ddev_has_irig_ctrl_bits( _p ) \ 1255 _pcps_has_irig_ctrl_bits( &(_p)->dev ) 1257 #define _pcps_ddev_has_irig_time( _p ) \ 1258 _pcps_has_irig_time( &(_p)->dev ) 1260 #define _pcps_ddev_has_raw_irig_data( _p ) \ 1261 _pcps_has_raw_irig_data( &(_p)->dev ) 1263 #define _pcps_ddev_has_ref_offs( _p ) \ 1264 _pcps_has_ref_offs( &(_p)->dev ) 1266 #define _pcps_ddev_has_opt_flags( _p ) \ 1267 _pcps_has_opt_flags( &(_p)->dev ) 1269 #define _pcps_ddev_has_gps_data_16( _p ) \ 1270 _pcps_has_gps_data_16( &(_p)->dev ) 1272 #define _pcps_ddev_has_gps_data( _p ) \ 1273 _pcps_has_gps_data( &(_p)->dev ) 1275 #define _pcps_ddev_has_synth( _p ) \ 1276 _pcps_has_synth( &(_p)->dev ) 1278 #define _pcps_ddev_has_generic_io( _p ) \ 1279 _pcps_has_generic_io( &(_p)->dev ) 1281 #define _pcps_ddev_has_time_scale( _p ) \ 1282 _pcps_has_time_scale( &(_p)->dev ) 1284 #define _pcps_ddev_has_utc_parm( _p ) \ 1285 _pcps_has_utc_parm( &(_p)->dev ) 1287 #define _pcps_ddev_has_asic_version( _p ) \ 1288 _pcps_has_asic_version( &(_p)->dev ) 1290 #define _pcps_ddev_has_asic_features( _p ) \ 1291 _pcps_has_asic_features( &(_p)->dev ) 1293 #define _pcps_ddev_has_fast_hr_timestamp( _p ) \ 1294 _pcps_has_fast_hr_timestamp( &(_p)->dev ) 1296 #define _pcps_ddev_has_lan_intf( _p ) \ 1297 _pcps_has_lan_intf( &(_p)->dev ) 1299 #define _pcps_ddev_has_ptp( _p ) \ 1300 _pcps_has_ptp( &(_p)->dev ) 1302 #define _pcps_ddev_has_ptp_unicast( _p ) \ 1303 _pcps_has_ri_ptp_unicast( _ri_addr( _p ) ) 1305 #define _pcps_ddev_has_pzf( _p ) \ 1306 _pcps_has_pzf( &(_p)->dev ) 1308 #define _pcps_ddev_has_corr_info( _p ) \ 1309 _pcps_has_corr_info( &(_p)->dev ) 1311 #define _pcps_ddev_has_tr_distance( _p ) \ 1312 _pcps_has_tr_distance( &(_p)->dev ) 1314 #define _pcps_ddev_has_evt_log( _p ) \ 1315 _pcps_has_evt_log( &(_p)->dev ) 1317 #define _pcps_ddev_has_debug_status( _p ) \ 1318 _pcps_has_debug_status( &(_p)->dev ) 1320 #define _pcps_ddev_has_stat_info( _p ) \ 1321 _pcps_has_stat_info( &(_p)->dev ) 1323 #define _pcps_ddev_has_stat_info_mode( _p ) \ 1324 _pcps_has_stat_info_mode( &(_p)->dev ) \ 1326 #define _pcps_ddev_has_stat_info_svs( _p ) \ 1327 _pcps_has_stat_info_svs( &(_p)->dev ) \ 1329 #define _pcps_ddev_incoming_tfom_ignored( _p ) \ 1330 _pcps_incoming_tfom_ignored( &(_p)->dev ) 1332 #define _pcps_ddev_pci_cfg_err( _p ) \ 1333 _pcps_pci_cfg_err( &(_p)->dev ) 1335 #define _pcps_ddev_has_gpio( _p ) \ 1336 _pcps_has_ri_gpio( _ri_addr( _p ) ) 1338 #define _pcps_ddev_has_xmr( _p ) \ 1339 _pcps_has_ri_xmr( _ri_addr( _p ) ) 1341 #define _pcps_ddev_fw_has_20ms_bug( _p ) \ 1342 _pcps_fw_has_20ms_bug( &(_p)->dev ) 1349 #if !defined( _pcps_read ) 1350 #define _pcps_read( _pddev, _cmd, _p, _n ) \ 1351 ( (_pddev)->read( _pddev, (_cmd), (uchar FAR *)(_p), (_n) ) ) 1357 #if !defined( _pcps_write_byte ) 1358 #define _pcps_write_byte( _pddev, _b ) \ 1359 _pcps_read( (_pddev), (_b), NULL, 0 ) 1365 #if !defined( _pcps_write ) 1366 #define _pcps_write( _pddev, _cmd, _p, _n ) \ 1367 pcps_write( (_pddev), (_cmd), (uchar FAR *)(_p), (_n) ) 1376 #define _pcps_read_gps( _pddev, _cmd, _p, _n ) \ 1377 pcps_read_gps( (_pddev), (_cmd), (uchar FAR *)(_p), (_n) ) 1380 #define _pcps_write_gps( _pddev, _cmd, _p, _n ) \ 1381 pcps_write_gps( (_pddev), (_cmd), (uchar FAR *)(_p), (_n) ) 1391 #define _pcps_read_var( _pddev, _cmd, _s ) \ 1392 _pcps_read( (_pddev), (_cmd), &(_s), sizeof( (_s) ) ) 1397 #define _pcps_write_var( _pddev, _cmd, _s ) \ 1398 _pcps_write( (_pddev), (_cmd), &(_s), sizeof( (_s) ) ) 1406 #define _pcps_read_gps_var( _pddev, _cmd, _s ) \ 1407 _pcps_read_gps( (_pddev), (_cmd), &(_s), sizeof( (_s) ) ) 1410 #define _pcps_write_gps_var( _pddev, _cmd, _s ) \ 1411 _pcps_write_gps( (_pddev), (_cmd), &(_s), sizeof( (_s) ) ) 1417 #define _pcps_force_reset( _pddev ) \ 1418 _pcps_write_byte( (_pddev), PCPS_FORCE_RESET ) 1439 #define _pcps_ddev_read_status_port( _d ) \ 1440 ( _pcps_ddev_access_mode_mm( (_d) ) ? \ 1441 _mbg_mmrd8( &(_d)->mm_asic_addr->status_port.b ) : \ 1442 _mbg_inp8( (_d), 0, (_d)->status_port ) \ 1449 #define _pcps_ddev_read_status_port( _d ) \ 1450 _mbg_inp8( (_d), 0, (_d)->status_port ) 1455 #define _pcps_ddev_status_busy( _d ) \ 1456 ( _pcps_ddev_read_status_port( pddev ) & PCPS_ST_BUSY ) 1463 #define _pcps_ddev_requires_irig_workaround( _d ) \ 1464 ( ( _pcps_ddev_type_num( _d ) == PCPS_TYPE_GPS169PCI ) && \ 1465 ( _pcps_ddev_fw_rev_num( _d ) < REV_HAS_GPS_DATA_16_GPS169PCI ) ) 1470 #if !defined( MBGUSB_TIMEOUT_SEND_MS ) 1471 #define MBGUSB_TIMEOUT_SEND_MS 500 // [ms] 1474 #if !defined( MBGUSB_TIMEOUT_RECEIVE_MS ) 1475 #define MBGUSB_TIMEOUT_RECEIVE_MS 500 // [ms] 1478 #if !defined( MBGUSB_TIMEOUT_RECEIVE_CYCLIC_MS ) 1486 #if !defined( _PCPS_USB_FULL_CYCLIC_INTV ) 1487 #define _PCPS_USB_FULL_CYCLIC_INTV 1 1490 #if _PCPS_USB_FULL_CYCLIC_INTV 1491 #define MBGUSB_TIMEOUT_RECEIVE_CYCLIC_MS 1200 1493 #define MBGUSB_TIMEOUT_RECEIVE_CYCLIC_MS 50 1498 #if !defined( _pcps_ms_to_usb_timeout ) 1499 #define _pcps_ms_to_usb_timeout( _ms ) (_ms) 1503 #if !defined( MBGUSB_TIMEOUT_SEND ) 1504 #define MBGUSB_TIMEOUT_SEND _pcps_ms_to_usb_timeout( MBGUSB_TIMEOUT_SEND_MS ) 1507 #if !defined( MBGUSB_TIMEOUT_RECEIVE ) 1508 #define MBGUSB_TIMEOUT_RECEIVE _pcps_ms_to_usb_timeout( MBGUSB_TIMEOUT_RECEIVE_MS ) 1511 #if !defined( MBGUSB_TIMEOUT_RECEIVE_CYCLIC ) 1512 #define MBGUSB_TIMEOUT_RECEIVE_CYCLIC _pcps_ms_to_usb_timeout( MBGUSB_TIMEOUT_RECEIVE_CYCLIC_MS ) 1517 #if !defined( MBG_TGT_WIN32 ) 1520 int pcps_direct_usb_transfer(
PCPS_DDEV *pddev,
void *buffer,
int len,
int ep_idx,
1521 int timeout,
const char *fnc_name )
1525 #if defined( MBG_TGT_LINUX ) 1528 unsigned int ep = pddev->ep[ep_idx].addr;
1529 bool rcv = is_ep_rcv( ep );
1530 int pipe = rcv ? usb_rcvbulkpipe( pddev->udev, ep )
1531 : usb_sndbulkpipe( pddev->udev, ep );
1537 #if _PCPS_CHK_BUFFER_DMA_CAPABLE 1551 memcpy( p, buffer, len );
1553 usb_rc = usb_bulk_msg( pddev->udev, pipe, p, len, &actual_len, timeout );
1555 if ( rcv && ( usb_rc == 0 ) )
1556 memcpy( buffer, p, actual_len );
1562 usb_rc = usb_bulk_msg( pddev->udev, pipe, buffer, len, &actual_len, timeout );
1565 #if DEBUG_USB_IO > 1 1567 fnc_name, ep, pipe, p ? p : NULL, len, actual_len, timeout, usb_rc );
1574 #if DEBUG_USB_IO > 1 1583 #error Needs to be implemented for this target. 1593 int pcps_direct_usb_transfer(
PCPS_DDEV *pddev,
void *buffer,
int len,
int ep_idx,
int timeout,
const char *fnc_name );
1600 int pcps_direct_usb_write(
PCPS_DDEV *pddev,
void *buffer,
int len )
1603 MBGUSB_TIMEOUT_SEND, __func__ );
1607 #define _pcps_direct_usb_write_var( _d, _p ) \ 1608 pcps_direct_usb_write( _d, _p, sizeof( *(_p) ) ) 1613 int pcps_direct_usb_read(
PCPS_DDEV *pddev,
void *buffer,
int len )
1616 MBGUSB_TIMEOUT_RECEIVE, __func__ );
1620 #define _pcps_direct_usb_read_var( _d, _p ) \ 1621 pcps_direct_usb_read( _d, _p, sizeof( *(_p) ) ) 1626 int pcps_direct_usb_read_cyclic(
PCPS_DDEV *pddev,
void *buffer,
int len )
1629 MBGUSB_TIMEOUT_RECEIVE_CYCLIC, __func__ );
1633 #define _pcps_direct_usb_read_var_cyclic( _d, _p ) \ 1634 pcps_direct_usb_read_cyclic( _d, _p, sizeof( *(_p) ) ) 1651 void pcps_dump_data(
const void *buffer,
size_t count,
const char *info ) ;
#define N_PCPS_MEM_RSRC
The max number of bus memory resources used by a device.
#define USB_DEV_WWVB51USB
#define _pcps_ddev_sernum(_p)
PCPS_RSRC_INFO rsrc_info
Summary of resources used by the device.
void pcps_cleanup_ddev(PCPS_DDEV *pddev)
Clean up and free a previously initialized device info structure.
uint32_t irq_disb_mask
Bit mask to be cleared to disable IRQs.
const char * fw_id_ref[]
The first characters of a valid firmware ID.
#define PCI_DEV_TCR170PEX
#define _mbg_kdd_msg_4(_lvl, _fmt, _p1, _p2, _p3, _p4)
struct fasync_struct * fasyncptr
Used for asynchronous signalling when data is available.
void pcps_detect_devices(int isa_ports[16], int isa_irqs[16])
Detect all bus-level devices in a non-PnP system.
int PCPS_WRITE_FNC(PCPS_DDEV *pddev, uint8_t cmd, const void *buffer, uint16_t count)
uint8_t cmd
In case of small data we just need one of the PCPS_CMD_CODES.
#define PCI_DEV_TCR510PCI
#define _mbgddmsg_3(_f, _lvl, _fmt, _p1, _p2, _p3)
#define PCI_DEV_TCR167PCI
#define ISA_ID_PCPS
A board ID for later ISA bus devices.
PTP/IEEE1588 network protocol.
PCPS_TIME t
Date and time read by IRQ handler.
#define USB_DEV_TCR600USB
PCPS_IRQ_STAT_INFO irq_stat_info
unsigned long jiffies_at_irq
Set by IRQ handler, used to check if cyclic IRQs still occur.
int pcps_read_gps(PCPS_DDEV *pddev, uint8_t data_type, void *buffer, uint16_t count)
Read a large data structure from a device.
ulong MBG_IOPORT_ADDR_MAPPED
uint32_t BUILTIN_FEATURE_MASK
Definitions used to classify devices and built-in features.
uint8_t gps_cmd
One of the PC_GPS_CMD_CODES.
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.
void pcps_dump_data(const void *buffer, size_t count, const char *info)
#define MBG_DEV_NAME_FMT
A string format specifier for MBG_DEV_NAME.
uint32_t irq_flag_mask
Bit mask used to check if device has generated an IRQ.
#define PCI_DEV_PZF180PEX
Resource info summary for a device.
#define _MBG_INIT_CODE_ATTR
#define PCI_DEV_GPS180PEX
MBG_IOPORT_ADDR_MAPPED irq_ack_port
Address of the register to acknowledge an IRQ.
#define PCI_DEV_GNS181PEX
#define PCI_DEV_GPS167PCI
#define PCI_DEV_GPS170PCI
Memory layout of Meinberg PCI interface register.
PCPS_DEV_TYPE pcps_dev_type[N_PCPS_DEV_TYPE]
int pcps_write(PCPS_DDEV *pddev, uint8_t cmd, const void *buffer, uint16_t count)
Write data to a device.
#define PCI_DEV_PCI32
PCI device IDs assigned by Meinberg.
int num_rsrc_io
Number of actually assigned I/O address ranges.
#define PCI_DEV_TCR511PCI
atomic_t open_count
Number of processes that have opened this device.
#define MCA_ID_PS31
MCA adapter ID assigned by IBM.
#define _pcps_ddev_access_mode_mm(_p)
int mbg_posix_errno_to_mbg(int posix_errno, const char *info)
Translate a POSIX errno error code to one of the MBG_ERROR_CODES.
int num_rsrc_irq
Number of actually assigned IRQ numbers.
MBG_XDEV_FEATURES xdev_features
Receiver info plus extended device features.
PCPS_READ_FNC * read
Pointer to the read function depending on the access mode.
MBG_PC_CYCLES acc_cycles
Cycles count taken when device was accessed last time.
32 bit memory mapped access
No real I/O, dummy routine used.
Register layout of a PCI ASIC.
PCI_ASIC_VERSION asic_version
ASIC version.
IRIG or similar time code, see http://www.meinberg.de/english/info/irig.htm.
uint64_t MBG_IOMEM_ADDR_RAW
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[16], int isa_irqs[16])
Detect and initialize ISA devices in a non-PnP system.
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.
uint32_t irq_enb_mask
Bit mask to be set to enable IRQs.
int PCPS_READ_FNC(PCPS_DDEV *pddev, uint8_t cmd, void *buffer, uint16_t count)
#define PCPS_BUS_ISA
IBM compatible PC/AT ISA bus.
#define MCA_ID_PS31_OLD
MCA adapter ID assigned by Meinberg, used with the first series of PS31 boards.
#define PCPS_BUS_PCI_S5933
bool access_mode_forced
Flag indicating that the access mode was forced.
uint32_t PCI_ASIC_FEATURES
A data type to hold the PCI ASIC feature flags mask.
PCPS_ACCESS_MODES
Codes used with PCPS_DDEV::access_mode.
dev_t lx_dev
Linux device associated with this device.
PCI_ASIC_VERSION raw_asic_version
Raw ASIC version.
PCI_ASIC volatile __iomem * mm_asic_addr
int pcps_generic_io(PCPS_DDEV *pddev, uint8_t type, const void *in_buff, uint8_t in_cnt, void *out_buff, uint8_t out_cnt)
Generic I/O function.
#define N_PCPS_PORT_RSRC
The max. number of I/O port resources used by a clock.
PCPS_TIME_STAMP volatile __iomem * mm_tstamp_addr
int pcps_write_gps(PCPS_DDEV *pddev, uint8_t data_type, const void *buffer, uint16_t count)
Write a large data structure to a device.
#define _mbg_inp8(_dev, _rsrc_idx, _port_addr)
#define PCI_DEV_GPS169PCI
int num_rsrc_mem
Number of actually assigned memory address ranges.
#define USB_DEV_DCF600USB
int PCPS_DDEV_REGISTER_FNC(PCPS_DDEV *pddev)
MBG_IOPORT_ADDR_MAPPED status_port_offs
#define PCPS_BUS_PCI_MBGPEX
void pcps_detect_pci_devices(PCPS_DDEV_INIT_FNC *ddev_init_fnc, PCPS_DDEV_CLEANUP_FNC *ddev_cleanup_fnc, ushort vendor_id, PCPS_DEV_TYPE dev_type[], int n_dev_types)
Detect and initialize PCI devices in a non-PnP system.
DCF77 long wave signal (Germany), see http://www.meinberg.de/english/info/dcf77.htm.
void pcps_release_rsrcs(PCPS_DDEV *pddev)
Release I/O port and memory resource that have been claimed before.
BUILTIN_FEATURE_MASK builtin_features
Mask of builtin features, depending on device type.
IRQ resource information for a device.
#define MBG_ERR_NO_MEM
Failed to allocate memory.
#define _mbgddmsg_8(_f, _lvl, _fmt, _p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8)
#define _pcps_kmalloc(_sz)
An I/O buffer for bus level devices.
uint32_t PCPS_IRQ_STAT_INFO
PCI_ASIC_FEATURES asic_features
ASIC feature mask.
#define PCPS_BUS_MCA
IBM PS/2 micro channel.
void pcps_cleanup_device(PCPS_DDEV *pddev)
Clean up function called by pcps_probe_device on error.
MSF long wave signal (UK)
atomic_t connected
Flag indicating if the device is "connected".
#define USB_DEV_WVB600USB
#define _pcps_kfree(_p, _sz)
16 bit memory mapped access
#define USB_DEV_MSF600USB
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.
MBG_IOPORT_ADDR_MAPPED irq_enb_disb_port
Address of the IRQ control register.
uint access_mode
Access mode used for the device, depending on interface type. See PCPS_ACCESS_MODES.
#define _pcps_ddev_type_name(_p)
GPS satellite system, see http://www.meinberg.de/english/info/gps.htm.
Device type specification.
atomic_t access_in_progress
Flag indicating if device access is currently in progress.
I/O port resource information for a device.
#define PCI_DEV_TCR511PEX
static __mbg_inline uint8_t _pcps_ddev_read_status_port(const PCPS_DDEV *pddev)
ulong MBG_IOPORT_ADDR_RAW
#define PCI_DEV_PTP270PEX
#define PCPS_BUS_PCI_S5920
int pcps_init_ddev(PCPS_DDEV **ppddev)
Allocate and initialize a device info structure.
#define PCI_DEV_GPS168PCI
#define PCI_DEV_GPS170PEX
uint32_t PCI_ASIC_VERSION
A data type to hold the PCI ASIC version code.
void check_receiver_info_and_features(PCPS_DDEV *pddev)
Check the receiver info and features.
int pcps_setup_ddev(PCPS_DDEV *pddev, PCPS_BUS_FLAGS bus_mask, PCPS_DEV_ID dev_id)
Initialize an allocated device structure for a specific device.
Local calendar date and time, plus sync status.
atomic_t data_avail
Flag indicating if data has been made available by IRQ handler.
A high resolution time stamp.
WWVB long wave signal (U.S.)
A structure combining all device feature information.
#define PCPS_BUS_PCI_ASIC
MBG_IOPORT_ADDR_MAPPED status_port
Address of the status port register.
int pcps_add_rsrc_irq(PCPS_DDEV *pddev, int16_t irq_num)
Add an IRQ number resource to the device structure.
#define _pcps_buffer_is_dma_capable(_b)
#define PCPS_MAX_ISA_CARDS
#define PCI_DEV_FRC511PEX
uint32_t irq_ack_mask
Bit mask to be set to acknowledge an IRQ.
#define PCI_DEV_GPS180AMC
MBG_IRQ_RSRC irq
Info on actually assigned IRQ numbers.
MBG_MUTEX dev_mutex
Mutex used for device access serialization.
#define USB_DEV_TCR180USB
#define PCI_DEV_GLN180PEX
#define _mbg_mmrd8_offs(_dev, _rsrc_idx, _iomem_offs)
int PCPS_DDEV_INIT_FNC(PCPS_DDEV **ppddev)
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.
PCPS_DEV dev
Device info data that can be passed to user space.
int64_t MBG_PC_CYCLES
Generic types to hold PC cycle counter values.
pthread_mutex_t MBG_MUTEX
#define MBG_ERR_NOT_SUPP_ON_OS
Function is not supported on this operating system.
MBG_IOPORT_ADDR_MAPPED irq_flag_port
Address of the IRQ status register.
Bus memory resource information for a device.
int pcps_setup_and_start_pci_dev(PCPS_DDEV *pddev, PCPS_BUS_NUM bus_num, PCPS_SLOT_NUM dev_fnc_num)
Setup and start a PCI device in a non-PnP system.
#define PCPS_BUS_PCI_PEX8311
void PCPS_DDEV_CLEANUP_FNC(PCPS_DDEV *pddev)
USB I/O, no direct port access.
struct wait_queue * wait_queue
Used for asynchronous I/O (older kernel API)
#define PCI_DEV_TCR180PEX
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.
int setup_sernum_and_receiver_info(PCPS_DDEV *pddev)
Read the serial number and receiver info from the device.