xref: /freebsd/sys/dev/cfe/cfe_ioctl.h (revision 2e3507c25e42292b45a5482e116d278f5515d04d)
1 /*-
2  * SPDX-License-Identifier: BSD-3-Clause
3  *
4  * Copyright 2000, 2001, 2002, 2003
5  * Broadcom Corporation. All rights reserved.
6  *
7  * This software is furnished under license and may be used and
8  * copied only in accordance with the following terms and
9  * conditions.  Subject to these conditions, you may download,
10  * copy, install, use, modify and distribute modified or unmodified
11  * copies of this software in source and/or binary form.  No title
12  * or ownership is transferred hereby.
13  *
14  * 1) Any source code used, modified or distributed must reproduce and
15  *    retain this copyright notice and list of conditions as they appear in
16  *    the source file.
17  *
18  * 2) No right is granted to use any trade name, trademark, or logo of
19  *    Broadcom Corporation.  The "Broadcom Corporation" name may not be
20  *    used to endorse or promote products derived from this software
21  *    without the prior written permission of Broadcom Corporation.
22  *
23  * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
24  *    WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
25  *    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
26  *    NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
27  *    FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
28  *    LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  *    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  *    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31  *    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32  *    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
33  *    OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 /*  *********************************************************************
37     *  Broadcom Common Firmware Environment (CFE)
38     *
39     *  IOCTL definitions			File: cfe_ioctl.h
40     *
41     *  IOCTL function numbers and I/O data structures.
42     *
43     *  Author:  Mitch Lichtenberg
44     *
45     ********************************************************************* */
46 
47 /*  *********************************************************************
48     *  NVFAM and FLASH stuff
49     ********************************************************************* */
50 
51 #define IOCTL_NVRAM_GETINFO	1	/* return nvram_info_t */
52 #define IOCTL_NVRAM_ERASE	2	/* erase sector containing nvram_info_t area */
53 #define IOCTL_FLASH_ERASE_SECTOR 3	/* erase an arbitrary sector */
54 #define IOCTL_FLASH_ERASE_ALL   4	/* Erase the entire flash */
55 #define IOCTL_FLASH_WRITE_ALL	5	/* write entire flash */
56 #define IOCTL_FLASH_GETINFO	6	/* get flash device info */
57 #define IOCTL_FLASH_GETSECTORS	7	/* get sector information */
58 #define IOCTL_FLASH_ERASE_RANGE 8	/* erase range of bytes */
59 #define IOCTL_NVRAM_UNLOCK	9	/* allow r/w beyond logical end of device */
60 #define IOCTL_FLASH_PROTECT_RANGE 10	/* Protect a group of sectors */
61 #define IOCTL_FLASH_UNPROTECT_RANGE 11	/* unprotect a group of sectors */
62 #define IOCTL_FLASH_DATA_WIDTH_MODE	12 	/* switch flash and gen bus to support 8 or 16-bit mode I/Os */
63 #define IOCTL_FLASH_BURST_MODE	13	/* configure gen bus for burst mode */
64 
65 typedef struct flash_range_s {
66     unsigned int range_base;
67     unsigned int range_length;
68 } flash_range_t;
69 
70 typedef struct flash_info_s {
71     unsigned long long flash_base;	/* flash physical base address */
72     unsigned int flash_size;		/* available device size in bytes */
73     unsigned int flash_type;		/* type, from FLASH_TYPE below */
74     unsigned int flash_flags;		/* Various flags (FLASH_FLAG_xxx) */
75 } flash_info_t;
76 
77 typedef struct flash_sector_s {
78     int flash_sector_idx;
79     int flash_sector_status;
80     unsigned int flash_sector_offset;
81     unsigned int flash_sector_size;
82 } flash_sector_t;
83 
84 #define FLASH_SECTOR_OK		0
85 #define FLASH_SECTOR_INVALID	-1
86 
87 #define FLASH_TYPE_UNKNOWN	0	/* not sure what kind of flash */
88 #define FLASH_TYPE_SRAM		1	/* not flash: it's SRAM */
89 #define FLASH_TYPE_ROM		2	/* not flash: it's ROM */
90 #define FLASH_TYPE_FLASH	3	/* it's flash memory of some sort */
91 
92 #define FLASH_FLAG_NOERASE	1	/* Byte-range writes supported,
93 					   Erasing is not necessary */
94 
95 typedef struct nvram_info_s {
96     int nvram_offset;			/* offset of environment area */
97     int nvram_size;			/* size of environment area */
98     int nvram_eraseflg;			/* true if we need to erase first */
99 } nvram_info_t;
100 
101 /*  *********************************************************************
102     *  Ethernet stuff
103     ********************************************************************* */
104 
105 #define IOCTL_ETHER_GETHWADDR	1	/* Get hardware address (6bytes) */
106 #define IOCTL_ETHER_SETHWADDR   2	/* Set hardware address (6bytes) */
107 #define IOCTL_ETHER_GETSPEED    3	/* Get Speed and Media (int) */
108 #define IOCTL_ETHER_SETSPEED    4	/* Set Speed and Media (int) */
109 #define IOCTL_ETHER_GETLINK	5	/* get link status (int) */
110 #define IOCTL_ETHER_GETLOOPBACK	7	/* get loopback state */
111 #define IOCTL_ETHER_SETLOOPBACK	8	/* set loopback state */
112 #define IOCTL_ETHER_SETPACKETFIFO 9	/* set packet fifo mode (int) */
113 #define IOCTL_ETHER_SETSTROBESIG 10	/* set strobe signal (int) */
114 
115 #define ETHER_LOOPBACK_OFF	0	/* no loopback */
116 #define ETHER_LOOPBACK_INT	1	/* Internal loopback */
117 #define ETHER_LOOPBACK_EXT	2	/* External loopback (through PHY) */
118 
119 #define ETHER_SPEED_AUTO	0	/* Auto detect */
120 #define ETHER_SPEED_UNKNOWN	0	/* Speed not known (on link status) */
121 #define ETHER_SPEED_10HDX	1	/* 10MB hdx and fdx */
122 #define ETHER_SPEED_10FDX	2
123 #define ETHER_SPEED_100HDX	3	/* 100MB hdx and fdx */
124 #define ETHER_SPEED_100FDX	4
125 #define ETHER_SPEED_1000HDX	5	/* 1000MB hdx and fdx */
126 #define ETHER_SPEED_1000FDX	6
127 
128 #define ETHER_FIFO_8		0	/* 8-bit packet fifo mode */
129 #define ETHER_FIFO_16		1	/* 16-bit packet fifo mode */
130 #define ETHER_ETHER		2	/* Standard ethernet mode */
131 
132 #define ETHER_STROBE_GMII	0	/* GMII style strobe signal */
133 #define ETHER_STROBE_ENCODED	1	/* Encoded */
134 #define ETHER_STROBE_SOP	2	/* SOP flagged. Only in 8-bit mode*/
135 #define ETHER_STROBE_EOP	3	/* EOP flagged. Only in 8-bit mode*/
136 
137 /*  *********************************************************************
138     *  Serial Ports
139     ********************************************************************* */
140 
141 #define IOCTL_SERIAL_SETSPEED	1	/* get baud rate (int) */
142 #define IOCTL_SERIAL_GETSPEED	2	/* set baud rate (int) */
143 #define IOCTL_SERIAL_SETFLOW	3	/* Set Flow Control */
144 #define IOCTL_SERIAL_GETFLOW	4	/* Get Flow Control */
145 
146 #define SERIAL_FLOW_NONE	0	/* no flow control */
147 #define SERIAL_FLOW_SOFTWARE	1	/* software flow control (not impl) */
148 #define SERIAL_FLOW_HARDWARE	2	/* hardware flow control */
149 
150 /*  *********************************************************************
151     *  Block device stuff
152     ********************************************************************* */
153 
154 #define IOCTL_BLOCK_GETBLOCKSIZE 1	/* get block size (int) */
155 #define IOCTL_BLOCK_GETTOTALBLOCKS 2	/* get total bocks (long long) */
156 #define IOCTL_BLOCK_GETDEVTYPE 3	/* get device type (struct) */
157 
158 typedef struct blockdev_info_s {
159     unsigned long long blkdev_totalblocks;
160     unsigned int blkdev_blocksize;
161     unsigned int blkdev_devtype;
162 } blockdev_info_t;
163 
164 #define BLOCK_DEVTYPE_DISK	0
165 #define BLOCK_DEVTYPE_CDROM	1
166