Merge branch 'omap-serial' of git://git.linaro.org/people/rmk/linux-arm
[firefly-linux-kernel-4.4.55.git] / drivers / staging / csr / unifi_dbg.c
1 /*
2  * ***************************************************************************
3  *  FILE:     unifi_dbg.c
4  *
5  *  PURPOSE:
6  *      Handle debug signals received from UniFi.
7  *
8  * Copyright (C) 2007-2008 by Cambridge Silicon Radio Ltd.
9  *
10  * Refer to LICENSE.txt included with this source code for details on
11  * the license terms.
12  *
13  * ***************************************************************************
14  */
15 #include "unifi_priv.h"
16
17 /*
18  * ---------------------------------------------------------------------------
19  *  debug_string_indication
20  *  debug_word16_indication
21  *
22  *      Handlers for debug indications.
23  *
24  *  Arguments:
25  *      priv            Pointer to private context structure.
26  *
27  *  Returns:
28  *      None.
29  * ---------------------------------------------------------------------------
30  */
31 void
32 debug_string_indication(unifi_priv_t *priv, const unsigned char *extra, unsigned int extralen)
33 {
34     const unsigned int maxlen = sizeof(priv->last_debug_string) - 1;
35
36     if (extralen > maxlen) {
37         extralen = maxlen;
38     }
39
40     strncpy(priv->last_debug_string, extra, extralen);
41
42     /* Make sure the string is terminated */
43     priv->last_debug_string[extralen] = '\0';
44
45     unifi_info(priv, "unifi debug: %s\n", priv->last_debug_string);
46
47 } /* debug_string_indication() */
48
49
50
51 void
52 debug_word16_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr)
53 {
54     int i;
55
56     if (priv == NULL) {
57         unifi_info(priv, "Priv is NULL\n");
58         return;
59     }
60
61     for (i = 0; i < 16; i++) {
62         priv->last_debug_word16[i] =
63                 sigptr->u.DebugWord16Indication.DebugWords[i];
64     }
65
66     if (priv->last_debug_word16[0] == 0xFA11) {
67         unsigned long ts;
68         ts = (priv->last_debug_word16[6] << 16) | priv->last_debug_word16[5];
69         unifi_info(priv, " %10lu: %s fault %04x, arg %04x (x%d)\n",
70                    ts,
71                    priv->last_debug_word16[3] == 0x8000 ? "MAC" :
72                    priv->last_debug_word16[3] == 0x4000 ? "PHY" :
73                    "???",
74                    priv->last_debug_word16[1],
75                    priv->last_debug_word16[2],
76                    priv->last_debug_word16[4]);
77     }
78     else if (priv->last_debug_word16[0] != 0xDBAC)
79         /* suppress SDL Trace output (note: still available to unicli). */
80     {
81         unifi_info(priv, "unifi debug: %04X %04X %04X %04X %04X %04X %04X %04X\n",
82                    priv->last_debug_word16[0], priv->last_debug_word16[1],
83                    priv->last_debug_word16[2], priv->last_debug_word16[3],
84                    priv->last_debug_word16[4], priv->last_debug_word16[5],
85                    priv->last_debug_word16[6], priv->last_debug_word16[7]);
86         unifi_info(priv, "             %04X %04X %04X %04X %04X %04X %04X %04X\n",
87                    priv->last_debug_word16[8], priv->last_debug_word16[9],
88                    priv->last_debug_word16[10], priv->last_debug_word16[11],
89                    priv->last_debug_word16[12], priv->last_debug_word16[13],
90                    priv->last_debug_word16[14], priv->last_debug_word16[15]);
91     }
92
93 } /* debug_word16_indication() */
94
95
96 void
97 debug_generic_indication(unifi_priv_t *priv, const CSR_SIGNAL *sigptr)
98 {
99     unifi_info(priv, "debug: %04X %04X %04X %04X %04X %04X %04X %04X\n",
100                sigptr->u.DebugGenericIndication.DebugWords[0],
101                sigptr->u.DebugGenericIndication.DebugWords[1],
102                sigptr->u.DebugGenericIndication.DebugWords[2],
103                sigptr->u.DebugGenericIndication.DebugWords[3],
104                sigptr->u.DebugGenericIndication.DebugWords[4],
105                sigptr->u.DebugGenericIndication.DebugWords[5],
106                sigptr->u.DebugGenericIndication.DebugWords[6],
107                sigptr->u.DebugGenericIndication.DebugWords[7]);
108
109 } /* debug_generic_indication() */
110