1193240Ssam/*-
2193240Ssam * Copyright (c) 2007-2009 Sam Leffler, Errno Consulting
3193240Ssam * Copyright (c) 2007-2009 Marvell Semiconductor, Inc.
4193240Ssam * All rights reserved.
5193240Ssam *
6193240Ssam * Redistribution and use in source and binary forms, with or without
7193240Ssam * modification, are permitted provided that the following conditions
8193240Ssam * are met:
9193240Ssam * 1. Redistributions of source code must retain the above copyright
10193240Ssam *    notice, this list of conditions and the following disclaimer,
11193240Ssam *    without modification.
12193240Ssam * 2. Redistributions in binary form must reproduce at minimum a disclaimer
13193240Ssam *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
14193240Ssam *    redistribution must be conditioned upon including a substantially
15193240Ssam *    similar Disclaimer requirement for further binary redistribution.
16193240Ssam *
17193240Ssam * NO WARRANTY
18193240Ssam * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19193240Ssam * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20193240Ssam * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
21193240Ssam * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22193240Ssam * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
23193240Ssam * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24193240Ssam * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25193240Ssam * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
26193240Ssam * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27193240Ssam * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28193240Ssam * THE POSSIBILITY OF SUCH DAMAGES.
29193240Ssam *
30193240Ssam * $FreeBSD$
31193240Ssam */
32193240Ssam
33193240Ssam#ifndef _MWL_DIAG_H_
34193240Ssam#define	_MWL_DIAG_H_
35193240Ssam/*
36193240Ssam * Diagnostic interface.  This is an open-ended interface that
37193240Ssam * is opaque to applications.  Diagnostic programs use this to
38193240Ssam * retrieve internal data structures, etc.  There is no guarantee
39193240Ssam * that calling conventions for calls other than MWL_DIAG_REVS
40193240Ssam * are stable between HAL releases; a diagnostic application must
41193240Ssam * use the HAL revision information to deal with ABI/API differences.
42193240Ssam *
43193240Ssam * NB: do not renumber these, certain codes are publicly used.
44193240Ssam */
45193240Ssamenum {
46193240Ssam	MWL_DIAG_CMD_REVS	= 0,	/* MAC/PHY/Radio revs */
47193240Ssam	MWL_DIAG_CMD_REGS	= 1,	/* Registers */
48193240Ssam	MWL_DIAG_CMD_HOSTCMD	= 2,	/* issue arbitrary cmd */
49193240Ssam	MWL_DIAG_CMD_FWLOAD	= 3,	/* load firmware */
50193240Ssam};
51193240Ssam
52193240Ssam/*
53193240Ssam * Device revision information.
54193240Ssam */
55193240Ssamtypedef struct {
56193240Ssam	uint16_t	mh_devid;		/* PCI device ID */
57193240Ssam	uint16_t	mh_subvendorid;		/* PCI subvendor ID */
58193240Ssam	uint16_t	mh_macRev;		/* MAC revision */
59193240Ssam	uint16_t	mh_phyRev;		/* PHY revision */
60193240Ssam} MWL_DIAG_REVS;
61193240Ssam
62193240Ssamtypedef struct {
63193240Ssam	uint16_t	start;		/* first register */
64193240Ssam	uint16_t	end;		/* ending register or zero */
65193240Ssam} MWL_DIAG_REGRANGE;
66193240Ssam
67193240Ssam/*
68193240Ssam * Registers are mapped into virtual banks; the hal converts
69193240Ssam * r/w operations through the diag api to host cmds as required.
70193240Ssam *
71193240Ssam * NB: register offsets are 16-bits and we need to avoid real
72193240Ssam *     register mappings in BAR1.
73193240Ssam */
74193240Ssam#define	MWL_DIAG_BASE_MAC	0xa000
75193240Ssam#define	MWL_DIAG_ISMAC(r) \
76193240Ssam	(MWL_DIAG_BASE_MAC <= (r) && (r) < (MWL_DIAG_BASE_MAC+0x1000))
77193240Ssam#define	MWL_DIAG_BASE_BB	0xe000
78193240Ssam#define	MWL_DIAG_ISBB(r) \
79193240Ssam	(MWL_DIAG_BASE_BB <= (r) && (r) < (MWL_DIAG_BASE_BB+0x1000))
80193240Ssam#define	MWL_DIAG_BASE_RF	0xf000
81193240Ssam#define	MWL_DIAG_ISRF(r) \
82193240Ssam	(MWL_DIAG_BASE_RF <= (r) && (r) < (MWL_DIAG_BASE_RF+0x1000))
83193240Ssam
84193240Ssam/*
85193240Ssam * Firmware download
86193240Ssam */
87193240Ssamtypedef struct {
88193240Ssam	uint32_t	opmode;			/* operating mode */
89193240Ssam	uint32_t	signature;		/* f/w ready signature */
90193240Ssam	char		name[1];		/* variable length pathname */
91193240Ssam} MWL_DIAG_FWLOAD;
92193240Ssam
93193240Ssamstruct mwl_diag {
94193240Ssam	char	md_name[IFNAMSIZ];	/* if name, e.g. "mv0" */
95193240Ssam	uint16_t md_id;
96193240Ssam#define	MWL_DIAG_DYN	0x8000		/* allocate buffer in caller */
97193240Ssam#define	MWL_DIAG_IN	0x4000		/* copy in parameters */
98193240Ssam#define	MWL_DIAG_OUT	0x0000		/* copy out results (always) */
99193240Ssam#define	MWL_DIAG_ID	0x0fff
100193240Ssam	uint16_t md_in_size;		/* pack to fit, yech */
101193240Ssam	void *	md_in_data;
102193240Ssam	void *	md_out_data;
103193240Ssam	u_int	md_out_size;
104193240Ssam
105193240Ssam};
106193240Ssam#define	SIOCGMVDIAG	_IOWR('i', 138, struct mwl_diag)
107193240Ssam#define	SIOCGMVRESET	_IOW('i', 139, struct mwl_diag)
108193240Ssam#endif /* _MWL_DIAG_H_ */
109