Beispiel #1
0
int wrc_ptp_set_mode(int mode)
{
	uint32_t start_tics, lock_timeout = 0;

	ptp_mode = 0;

	wrc_ptp_stop();

	switch (mode) {
	case WRC_MODE_GM:
		rtOpts.primarySource = TRUE;
		rtOpts.wrConfig = WR_M_ONLY;
		rtOpts.masterOnly = TRUE;
		spll_init(SPLL_MODE_GRAND_MASTER, 0, 1);
		lock_timeout = LOCK_TIMEOUT_GM;
		break;

	case WRC_MODE_MASTER:
		rtOpts.primarySource = FALSE;
		rtOpts.wrConfig = WR_M_ONLY;
		rtOpts.masterOnly = TRUE;
		spll_init(SPLL_MODE_FREE_RUNNING_MASTER, 0, 1);
		lock_timeout = LOCK_TIMEOUT_FM;
		break;

	case WRC_MODE_SLAVE:
		rtOpts.primarySource = FALSE;
		rtOpts.wrConfig = WR_S_ONLY;
		rtOpts.masterOnly = FALSE;
		spll_init(SPLL_MODE_SLAVE, 0, 1);
		break;
	}

	initDataClock(&rtOpts, &ptpClockDS);

	start_tics = timer_get_tics();

	mprintf("Locking PLL");

	shw_pps_gen_enable_output(0);

	while (!spll_check_lock(0) && lock_timeout) {
		timer_delay_ms(1000);
		mprintf(".");
		if (time_after(timer_get_tics(), start_tics + lock_timeout)) {
			mprintf("\nLock timeout.\n");
			return -ETIMEDOUT;
		} else if (uart_read_byte() == 27) {
			mprintf("\n");
			return -EINTR;
		}
	}
	mprintf("\n");

	if (mode == WRC_MODE_MASTER || mode == WRC_MODE_GM)
		shw_pps_gen_enable_output(1);

	ptp_mode = mode;
	return 0;
}
Beispiel #2
0
/* legacy function for 'calibration force' command */
int measure_t24p(uint32_t *value)
{
	int rv;
	pp_printf("Waiting for link...\n");
	while (!ep_link_up(NULL))
		timer_delay_ms(100);

	spll_init(SPLL_MODE_SLAVE, 0, 1);
	pp_printf("Locking PLL...\n");
	while (!spll_check_lock(0))
		timer_delay_ms(100);
	pp_printf("\n");

	pp_printf("Calibrating RX timestamper...\n");
	rxts_calibration_start();

	while (!(rv = rxts_calibration_update(value))) ;
	return rv;
}
int ptpd_netif_locking_enable(int txrx, const char *ifaceName, int priority)
{
  spll_init(SPLL_MODE_SLAVE, 0, 1);
  spll_enable_ptracker(0, 1);
  return PTPD_NETIF_OK;
}
Beispiel #4
0
int wrpc_spll_locking_enable(struct pp_instance *ppi)
{
	spll_init(SPLL_MODE_SLAVE, 0, 1);
	spll_enable_ptracker(0, 1);
	return WR_SPLL_OK;
}