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