162306a36Sopenharmony_ci/***********************license start***************
262306a36Sopenharmony_ci * Author: Cavium Networks
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Contact: support@caviumnetworks.com
562306a36Sopenharmony_ci * This file is part of the OCTEON SDK
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Copyright (c) 2003-2008 Cavium Networks
862306a36Sopenharmony_ci *
962306a36Sopenharmony_ci * This file is free software; you can redistribute it and/or modify
1062306a36Sopenharmony_ci * it under the terms of the GNU General Public License, Version 2, as
1162306a36Sopenharmony_ci * published by the Free Software Foundation.
1262306a36Sopenharmony_ci *
1362306a36Sopenharmony_ci * This file is distributed in the hope that it will be useful, but
1462306a36Sopenharmony_ci * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
1562306a36Sopenharmony_ci * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
1662306a36Sopenharmony_ci * NONINFRINGEMENT.  See the GNU General Public License for more
1762306a36Sopenharmony_ci * details.
1862306a36Sopenharmony_ci *
1962306a36Sopenharmony_ci * You should have received a copy of the GNU General Public License
2062306a36Sopenharmony_ci * along with this file; if not, write to the Free Software
2162306a36Sopenharmony_ci * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2262306a36Sopenharmony_ci * or visit http://www.gnu.org/licenses/.
2362306a36Sopenharmony_ci *
2462306a36Sopenharmony_ci * This file may also be available under a different license from Cavium.
2562306a36Sopenharmony_ci * Contact Cavium Networks for more information
2662306a36Sopenharmony_ci ***********************license end**************************************/
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci/**
2962306a36Sopenharmony_ci *
3062306a36Sopenharmony_ci * Fixes and workaround for Octeon chip errata. This file
3162306a36Sopenharmony_ci * contains functions called by cvmx-helper to workaround known
3262306a36Sopenharmony_ci * chip errata. For the most part, code doesn't need to call
3362306a36Sopenharmony_ci * these functions directly.
3462306a36Sopenharmony_ci *
3562306a36Sopenharmony_ci */
3662306a36Sopenharmony_ci#include <linux/export.h>
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci#include <asm/octeon/octeon.h>
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci#include <asm/octeon/cvmx-helper-jtag.h>
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci/**
4362306a36Sopenharmony_ci * Due to errata G-720, the 2nd order CDR circuit on CN52XX pass
4462306a36Sopenharmony_ci * 1 doesn't work properly. The following code disables 2nd order
4562306a36Sopenharmony_ci * CDR for the specified QLM.
4662306a36Sopenharmony_ci *
4762306a36Sopenharmony_ci * @qlm:    QLM to disable 2nd order CDR for.
4862306a36Sopenharmony_ci */
4962306a36Sopenharmony_civoid __cvmx_helper_errata_qlm_disable_2nd_order_cdr(int qlm)
5062306a36Sopenharmony_ci{
5162306a36Sopenharmony_ci	int lane;
5262306a36Sopenharmony_ci	cvmx_helper_qlm_jtag_init();
5362306a36Sopenharmony_ci	/* We need to load all four lanes of the QLM, a total of 1072 bits */
5462306a36Sopenharmony_ci	for (lane = 0; lane < 4; lane++) {
5562306a36Sopenharmony_ci		/*
5662306a36Sopenharmony_ci		 * Each lane has 268 bits. We need to set
5762306a36Sopenharmony_ci		 * cfg_cdr_incx<67:64> = 3 and cfg_cdr_secord<77> =
5862306a36Sopenharmony_ci		 * 1. All other bits are zero. Bits go in LSB first,
5962306a36Sopenharmony_ci		 * so start off with the zeros for bits <63:0>.
6062306a36Sopenharmony_ci		 */
6162306a36Sopenharmony_ci		cvmx_helper_qlm_jtag_shift_zeros(qlm, 63 - 0 + 1);
6262306a36Sopenharmony_ci		/* cfg_cdr_incx<67:64>=3 */
6362306a36Sopenharmony_ci		cvmx_helper_qlm_jtag_shift(qlm, 67 - 64 + 1, 3);
6462306a36Sopenharmony_ci		/* Zeros for bits <76:68> */
6562306a36Sopenharmony_ci		cvmx_helper_qlm_jtag_shift_zeros(qlm, 76 - 68 + 1);
6662306a36Sopenharmony_ci		/* cfg_cdr_secord<77>=1 */
6762306a36Sopenharmony_ci		cvmx_helper_qlm_jtag_shift(qlm, 77 - 77 + 1, 1);
6862306a36Sopenharmony_ci		/* Zeros for bits <267:78> */
6962306a36Sopenharmony_ci		cvmx_helper_qlm_jtag_shift_zeros(qlm, 267 - 78 + 1);
7062306a36Sopenharmony_ci	}
7162306a36Sopenharmony_ci	cvmx_helper_qlm_jtag_update(qlm);
7262306a36Sopenharmony_ci}
7362306a36Sopenharmony_ciEXPORT_SYMBOL(__cvmx_helper_errata_qlm_disable_2nd_order_cdr);
74