strip the kernel version suffix from target directories, except for brcm-2.4 (the...
[openwrt.git] / target / linux / brcm47xx / files / arch / mips / cfe / cfe_private.h
1 /*
2  * Broadcom Common Firmware Environment (CFE) support
3  *
4  * Copyright 2000, 2001, 2002
5  * Broadcom Corporation. All rights reserved.
6  *
7  * Copyright (C) 2006 Michael Buesch
8  *
9  * Original Authors:  Mitch Lichtenberg, Chris Demetriou
10  *
11  * This software is furnished under license and may be used and copied only
12  * in accordance with the following terms and conditions.  Subject to these
13  * conditions, you may download, copy, install, use, modify and distribute
14  * modified or unmodified copies of this software in source and/or binary
15  * form. No title or ownership is transferred hereby.
16  *
17  * 1) Any source code used, modified or distributed must reproduce and
18  *    retain this copyright notice and list of conditions as they appear in
19  *    the source file.
20  *
21  * 2) No right is granted to use any trade name, trademark, or logo of
22  *    Broadcom Corporation.  The "Broadcom Corporation" name may not be
23  *    used to endorse or promote products derived from this software
24  *    without the prior written permission of Broadcom Corporation.
25  *
26  * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
27  *    WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
28  *    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
29  *    NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
30  *    FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
31  *    LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32  *    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33  *    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
34  *    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
35  *    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
36  *    OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37  */
38
39 #ifndef LINUX_CFE_PRIVATE_H_
40 #define LINUX_CFE_PRIVATE_H_
41
42 #ifndef __ASSEMBLY__
43
44 /* Seal indicating CFE's presence, passed to the kernel. */
45 #define CFE_EPTSEAL             0x43464531
46
47 #define CFE_CMD_FW_GETINFO      0
48 #define CFE_CMD_FW_RESTART      1
49 #define CFE_CMD_FW_BOOT         2
50 #define CFE_CMD_FW_CPUCTL       3
51 #define CFE_CMD_FW_GETTIME      4
52 #define CFE_CMD_FW_MEMENUM      5
53 #define CFE_CMD_FW_FLUSHCACHE   6
54
55 #define CFE_CMD_DEV_GETHANDLE   9
56 #define CFE_CMD_DEV_ENUM        10
57 #define CFE_CMD_DEV_OPEN        11
58 #define CFE_CMD_DEV_INPSTAT     12
59 #define CFE_CMD_DEV_READ        13
60 #define CFE_CMD_DEV_WRITE       14
61 #define CFE_CMD_DEV_IOCTL       15
62 #define CFE_CMD_DEV_CLOSE       16
63 #define CFE_CMD_DEV_GETINFO     17
64
65 #define CFE_CMD_ENV_ENUM        20
66 #define CFE_CMD_ENV_GET         22
67 #define CFE_CMD_ENV_SET         23
68 #define CFE_CMD_ENV_DEL         24
69
70 #define CFE_CMD_MAX             32
71
72 #define CFE_CMD_VENDOR_USE      0x8000  /* codes above this are for customer use */
73
74 typedef u64 cfe_uint_t;
75 typedef s64 cfe_int_t;
76 typedef s64 cfe_ptr_t;
77
78 /* Cast a pointer from native to CFE-API pointer and back */
79 #define CFE_TO_PTR(p)           ((void *)(unsigned long)(p))
80 #define PTR_TO_CFE(p)           ((cfe_ptr_t)(unsigned long)(p))
81
82 struct cfe_iocb_buf {
83         cfe_uint_t      offset;         /* offset on device (bytes) */
84         cfe_ptr_t       ptr;            /* pointer to a buffer */
85         cfe_uint_t      length;         /* length of this buffer */
86         cfe_uint_t      retlen;         /* returned length (for read ops) */
87         union {
88                 cfe_uint_t      ioctlcmd;       /* IOCTL command (used only for IOCTLs) */
89                 cfe_uint_t      devflags;       /* Returned device info flags */
90         };
91 };
92
93 struct cfe_iocb_inpstat {
94         cfe_uint_t      status;         /* 1 means input available */
95 };
96
97 struct cfe_iocb_envbuf {
98         cfe_int_t       index;          /* 0-based enumeration index */
99         cfe_ptr_t       name;           /* name string buffer */
100         cfe_int_t       name_len;       /* size of name buffer */
101         cfe_ptr_t       val;            /* value string buffer */
102         cfe_int_t       val_len;        /* size of value string buffer */
103 };
104
105 struct cfe_iocb_cpuctl {
106         cfe_uint_t      number;         /* cpu number to control */
107         cfe_uint_t      command;        /* command to issue to CPU */
108         cfe_uint_t      start_addr;     /* CPU start address */
109         cfe_uint_t      gp;             /* starting GP value */
110         cfe_uint_t      sp;             /* starting SP value */
111         cfe_uint_t      a1;             /* starting A1 value */
112 };
113
114 struct cfe_iocb_time {
115         cfe_int_t       ticks;          /* current time in ticks */
116 };
117
118 struct cfe_iocb_exitstat {
119         cfe_int_t       status;
120 };
121
122 struct cfe_iocb_meminfo {
123         cfe_int_t       index;          /* 0-based enumeration index */
124         cfe_int_t       type;           /* type of memory block */
125         cfe_uint_t      addr;           /* physical start address */
126         cfe_uint_t      size;           /* block size */
127 };
128
129 struct cfe_iocb_fwinfo {
130         cfe_int_t       version;        /* major, minor, eco version */
131         cfe_int_t       totalmem;       /* total installed mem */
132         cfe_int_t       flags;          /* various flags */
133         cfe_int_t       boardid;        /* board ID */
134         cfe_int_t       bootarea_va;    /* VA of boot area */
135         cfe_int_t       bootarea_pa;    /* PA of boot area */
136         cfe_int_t       bootarea_size;  /* size of boot area */
137         cfe_int_t       reserved1;
138         cfe_int_t       reserved2;
139         cfe_int_t       reserved3;
140 };
141
142 /* CFE I/O Control Block */
143 struct cfe_iocb {
144         cfe_uint_t      fcode;          /* IOCB function code */
145         cfe_int_t       status;         /* return status */
146         cfe_int_t       handle;         /* file/device handle */
147         cfe_uint_t      flags;          /* flags for this IOCB */
148         cfe_uint_t      psize;          /* size of parameter list */
149         union {
150                 struct cfe_iocb_buf             buffer;         /* buffer parameters */
151                 struct cfe_iocb_inpstat         inpstat;        /* input status parameters */
152                 struct cfe_iocb_envbuf          envbuf;         /* environment function parameters */
153                 struct cfe_iocb_cpuctl          cpuctl;         /* CPU control parameters */
154                 struct cfe_iocb_time            time;           /* timer parameters */
155                 struct cfe_iocb_meminfo         meminfo;        /* memory arena info parameters */
156                 struct cfe_iocb_fwinfo          fwinfo;         /* firmware information */
157                 struct cfe_iocb_exitstat        exitstat;       /* Exit Status */
158         };
159 };
160
161
162 #include <linux/init.h>
163
164 void __init cfe_setup(unsigned long fwarg0, unsigned long fwarg1,
165                       unsigned long fwarg2, unsigned long fwarg3);
166
167 #else /* __ASSEMBLY__ */
168
169         .macro  cfe_early_init
170 #ifdef CONFIG_CFE
171                 jal     cfe_setup
172 #endif
173         .endm
174
175 #endif /* __ASSEMBLY__ */
176 #endif /* LINUX_CFE_PRIVATE_H_ */