]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/mwl/mwldiag.h
bsdinstall: remove VTOC8 partition scheme option
[FreeBSD/FreeBSD.git] / sys / dev / mwl / mwldiag.h
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting
5  * Copyright (c) 2007-2009 Marvell Semiconductor, Inc.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer,
13  *    without modification.
14  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
15  *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
16  *    redistribution must be conditioned upon including a substantially
17  *    similar Disclaimer requirement for further binary redistribution.
18  *
19  * NO WARRANTY
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
23  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
24  * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
25  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
28  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30  * THE POSSIBILITY OF SUCH DAMAGES.
31  *
32  * $FreeBSD$
33  */
34
35 #ifndef _MWL_DIAG_H_
36 #define _MWL_DIAG_H_
37 /*
38  * Diagnostic interface.  This is an open-ended interface that
39  * is opaque to applications.  Diagnostic programs use this to
40  * retrieve internal data structures, etc.  There is no guarantee
41  * that calling conventions for calls other than MWL_DIAG_REVS
42  * are stable between HAL releases; a diagnostic application must
43  * use the HAL revision information to deal with ABI/API differences.
44  *
45  * NB: do not renumber these, certain codes are publicly used.
46  */
47 enum {
48         MWL_DIAG_CMD_REVS       = 0,    /* MAC/PHY/Radio revs */
49         MWL_DIAG_CMD_REGS       = 1,    /* Registers */
50         MWL_DIAG_CMD_HOSTCMD    = 2,    /* issue arbitrary cmd */
51         MWL_DIAG_CMD_FWLOAD     = 3,    /* load firmware */
52 };
53
54 /*
55  * Device revision information.
56  */
57 typedef struct {
58         uint16_t        mh_devid;               /* PCI device ID */
59         uint16_t        mh_subvendorid;         /* PCI subvendor ID */
60         uint16_t        mh_macRev;              /* MAC revision */
61         uint16_t        mh_phyRev;              /* PHY revision */
62 } MWL_DIAG_REVS;
63
64 typedef struct {
65         uint16_t        start;          /* first register */
66         uint16_t        end;            /* ending register or zero */
67 } MWL_DIAG_REGRANGE;
68
69 /*
70  * Registers are mapped into virtual banks; the hal converts
71  * r/w operations through the diag api to host cmds as required.
72  *
73  * NB: register offsets are 16-bits and we need to avoid real
74  *     register mappings in BAR1.
75  */
76 #define MWL_DIAG_BASE_MAC       0xa000
77 #define MWL_DIAG_ISMAC(r) \
78         (MWL_DIAG_BASE_MAC <= (r) && (r) < (MWL_DIAG_BASE_MAC+0x1000))
79 #define MWL_DIAG_BASE_BB        0xe000
80 #define MWL_DIAG_ISBB(r) \
81         (MWL_DIAG_BASE_BB <= (r) && (r) < (MWL_DIAG_BASE_BB+0x1000))
82 #define MWL_DIAG_BASE_RF        0xf000
83 #define MWL_DIAG_ISRF(r) \
84         (MWL_DIAG_BASE_RF <= (r) && (r) < (MWL_DIAG_BASE_RF+0x1000))
85
86 /*
87  * Firmware download
88  */
89 typedef struct {
90         uint32_t        opmode;                 /* operating mode */
91         uint32_t        signature;              /* f/w ready signature */
92         char            name[1];                /* variable length pathname */
93 } MWL_DIAG_FWLOAD;
94
95 struct mwl_diag {
96         char    md_name[IFNAMSIZ];      /* if name, e.g. "mv0" */
97         uint16_t md_id;
98 #define MWL_DIAG_DYN    0x8000          /* allocate buffer in caller */
99 #define MWL_DIAG_IN     0x4000          /* copy in parameters */
100 #define MWL_DIAG_OUT    0x0000          /* copy out results (always) */
101 #define MWL_DIAG_ID     0x0fff
102         uint16_t md_in_size;            /* pack to fit, yech */
103         void *  md_in_data;
104         void *  md_out_data;
105         u_int   md_out_size;
106
107 };
108 #define SIOCGMVDIAG     _IOWR('i', 138, struct mwl_diag)
109 #define SIOCGMVRESET    _IOW('i', 139, struct mwl_diag)
110 #endif /* _MWL_DIAG_H_ */