/* Helper utilities for qlm_jtag. Initialize the internal QLM JTAG logic to allow programming of the JTAG chain by the cvmx_helper_qlm_jtag_*() functions. These functions should only be used at the direction of Cavium Networks. Programming incorrect values into the JTAG chain can cause chip damage.  */
void cvmx_helper_qlm_jtag_init(void)
/* Helper utilities for qlm_jtag. Initialize the internal QLM JTAG logic to allow programming of the JTAG chain by the cvmx_helper_qlm_jtag_*() functions. These functions should only be used at the direction of Cavium Networks. Programming incorrect values into the JTAG chain can cause chip damage.  */
void cvmx_helper_qlm_jtag_init(void)
{
	union cvmx_ciu_qlm_jtgc jtgc;
	uint32_t clock_div = 0;
	uint32_t divisor = cvmx_sysinfo_get()->cpu_clock_hz / (25 * 1000000);
	divisor = (divisor - 1) >> 2;
	while (divisor) {
		clock_div++;
		divisor = divisor >> 1;
	}
	jtgc.u64 = 0;
	jtgc.s.clk_div = clock_div;
	jtgc.s.mux_sel = 0;
	if (OCTEON_IS_MODEL(OCTEON_CN52XX))
		jtgc.s.bypass = 0x3;
	else
		jtgc.s.bypass = 0xf;
	cvmx_write_csr(CVMX_CIU_QLM_JTGC, jtgc.u64);
	cvmx_read_csr(CVMX_CIU_QLM_JTGC);
}