1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) 2020 Marvell International Ltd.
4  *
5  *  Helper utilities for qlm_jtag.
6  */
7 
8 #ifndef __CVMX_HELPER_JTAG_H__
9 #define __CVMX_HELPER_JTAG_H__
10 
11 /**
12  * The JTAG chain for CN52XX and CN56XX is 4 * 268 bits long, or 1072.
13  * CN5XXX full chain shift is:
14  *     new data => lane 3 => lane 2 => lane 1 => lane 0 => data out
15  * The JTAG chain for CN63XX is 4 * 300 bits long, or 1200.
16  * The JTAG chain for CN68XX is 4 * 304 bits long, or 1216.
17  * The JTAG chain for CN66XX/CN61XX/CNF71XX is 4 * 304 bits long, or 1216.
18  * CN6XXX full chain shift is:
19  *     new data => lane 0 => lane 1 => lane 2 => lane 3 => data out
20  * Shift LSB first, get LSB out
21  */
22 extern const __cvmx_qlm_jtag_field_t __cvmx_qlm_jtag_field_cn63xx[];
23 extern const __cvmx_qlm_jtag_field_t __cvmx_qlm_jtag_field_cn66xx[];
24 extern const __cvmx_qlm_jtag_field_t __cvmx_qlm_jtag_field_cn68xx[];
25 
26 #define CVMX_QLM_JTAG_UINT32 40
27 
28 typedef u32 qlm_jtag_uint32_t[CVMX_QLM_JTAG_UINT32 * 8];
29 
30 /**
31  * Initialize the internal QLM JTAG logic to allow programming
32  * of the JTAG chain by the cvmx_helper_qlm_jtag_*() functions.
33  * These functions should only be used at the direction of Cavium
34  * Networks. Programming incorrect values into the JTAG chain
35  * can cause chip damage.
36  */
37 void cvmx_helper_qlm_jtag_init(void);
38 
39 /**
40  * Write up to 32bits into the QLM jtag chain. Bits are shifted
41  * into the MSB and out the LSB, so you should shift in the low
42  * order bits followed by the high order bits. The JTAG chain for
43  * CN52XX and CN56XX is 4 * 268 bits long, or 1072. The JTAG chain
44  * for CN63XX is 4 * 300 bits long, or 1200.
45  *
46  * @param qlm    QLM to shift value into
47  * @param bits   Number of bits to shift in (1-32).
48  * @param data   Data to shift in. Bit 0 enters the chain first, followed by
49  *               bit 1, etc.
50  *
51  * @return The low order bits of the JTAG chain that shifted out of the
52  *         circle.
53  */
54 u32 cvmx_helper_qlm_jtag_shift(int qlm, int bits, u32 data);
55 
56 /**
57  * Shift long sequences of zeros into the QLM JTAG chain. It is
58  * common to need to shift more than 32 bits of zeros into the
59  * chain. This function is a convience wrapper around
60  * cvmx_helper_qlm_jtag_shift() to shift more than 32 bits of
61  * zeros at a time.
62  *
63  * @param qlm    QLM to shift zeros into
64  * @param bits
65  */
66 void cvmx_helper_qlm_jtag_shift_zeros(int qlm, int bits);
67 
68 /**
69  * Program the QLM JTAG chain into all lanes of the QLM. You must
70  * have already shifted in the proper number of bits into the
71  * JTAG chain. Updating invalid values can possibly cause chip damage.
72  *
73  * @param qlm    QLM to program
74  */
75 void cvmx_helper_qlm_jtag_update(int qlm);
76 
77 /**
78  * Load the QLM JTAG chain with data from all lanes of the QLM.
79  *
80  * @param qlm    QLM to program
81  */
82 void cvmx_helper_qlm_jtag_capture(int qlm);
83 
84 #endif /* __CVMX_HELPER_JTAG_H__ */
85