483be606960d06cd118b7b2f5e0edd21892ff00f
[linux-2.6-microblaze.git] / arch / mips / include / asm / lasat / lasat.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * lasat.h
4  *
5  * Thomas Horsten <thh@lasat.com>
6  * Copyright (C) 2000 LASAT Networks A/S.
7  *
8  * Configuration for LASAT boards, loads the appropriate include files.
9  */
10 #ifndef _LASAT_H
11 #define _LASAT_H
12
13 #ifndef _LANGUAGE_ASSEMBLY
14
15 extern struct lasat_misc {
16         volatile u32 *reset_reg;
17         volatile u32 *flash_wp_reg;
18         u32 flash_wp_bit;
19 } *lasat_misc;
20
21 enum lasat_mtdparts {
22         LASAT_MTD_BOOTLOADER,
23         LASAT_MTD_SERVICE,
24         LASAT_MTD_NORMAL,
25         LASAT_MTD_CONFIG,
26         LASAT_MTD_FS,
27         LASAT_MTD_LAST
28 };
29
30 /*
31  * The format of the data record in the EEPROM.
32  * See the LASAT Hardware Configuration field specification for a detailed
33  * description of the config field.
34  */
35 #include <linux/types.h>
36
37 #define LASAT_EEPROM_VERSION 7
38 struct lasat_eeprom_struct {
39         unsigned int  version;
40         unsigned int  cfg[3];
41         unsigned char hwaddr[6];
42         unsigned char print_partno[12];
43         unsigned char term0;
44         unsigned char print_serial[14];
45         unsigned char term1;
46         unsigned char prod_partno[12];
47         unsigned char term2;
48         unsigned char prod_serial[14];
49         unsigned char term3;
50         unsigned char passwd_hash[16];
51         unsigned char pwdnull;
52         unsigned char vendid;
53         unsigned char ts_ref;
54         unsigned char ts_signoff;
55         unsigned char reserved[11];
56         unsigned char debugaccess;
57         unsigned short prid;
58         unsigned int  serviceflag;
59         unsigned int  ipaddr;
60         unsigned int  netmask;
61         unsigned int  crc32;
62 };
63
64 struct lasat_eeprom_struct_pre7 {
65         unsigned int  version;
66         unsigned int  flags[3];
67         unsigned char hwaddr0[6];
68         unsigned char hwaddr1[6];
69         unsigned char print_partno[9];
70         unsigned char term0;
71         unsigned char print_serial[14];
72         unsigned char term1;
73         unsigned char prod_partno[9];
74         unsigned char term2;
75         unsigned char prod_serial[14];
76         unsigned char term3;
77         unsigned char passwd_hash[24];
78         unsigned char pwdnull;
79         unsigned char vendor;
80         unsigned char ts_ref;
81         unsigned char ts_signoff;
82         unsigned char reserved[6];
83         unsigned int  writecount;
84         unsigned int  ipaddr;
85         unsigned int  netmask;
86         unsigned int  crc32;
87 };
88
89 /* Configuration descriptor encoding - see the doc for details */
90
91 #define LASAT_W0_DSCTYPE(v)             (((v))         & 0xf)
92 #define LASAT_W0_BMID(v)                (((v) >> 0x04) & 0xf)
93 #define LASAT_W0_CPUTYPE(v)             (((v) >> 0x08) & 0xf)
94 #define LASAT_W0_BUSSPEED(v)            (((v) >> 0x0c) & 0xf)
95 #define LASAT_W0_CPUCLK(v)              (((v) >> 0x10) & 0xf)
96 #define LASAT_W0_SDRAMBANKSZ(v)         (((v) >> 0x14) & 0xf)
97 #define LASAT_W0_SDRAMBANKS(v)          (((v) >> 0x18) & 0xf)
98 #define LASAT_W0_L2CACHE(v)             (((v) >> 0x1c) & 0xf)
99
100 #define LASAT_W1_EDHAC(v)               (((v))         & 0xf)
101 #define LASAT_W1_HIFN(v)                (((v) >> 0x04) & 0x1)
102 #define LASAT_W1_ISDN(v)                (((v) >> 0x05) & 0x1)
103 #define LASAT_W1_IDE(v)                 (((v) >> 0x06) & 0x1)
104 #define LASAT_W1_HDLC(v)                (((v) >> 0x07) & 0x1)
105 #define LASAT_W1_USVERSION(v)           (((v) >> 0x08) & 0x1)
106 #define LASAT_W1_4MACS(v)               (((v) >> 0x09) & 0x1)
107 #define LASAT_W1_EXTSERIAL(v)           (((v) >> 0x0a) & 0x1)
108 #define LASAT_W1_FLASHSIZE(v)           (((v) >> 0x0c) & 0xf)
109 #define LASAT_W1_PCISLOTS(v)            (((v) >> 0x10) & 0xf)
110 #define LASAT_W1_PCI1OPT(v)             (((v) >> 0x14) & 0xf)
111 #define LASAT_W1_PCI2OPT(v)             (((v) >> 0x18) & 0xf)
112 #define LASAT_W1_PCI3OPT(v)             (((v) >> 0x1c) & 0xf)
113
114 /* Routines specific to LASAT boards */
115
116 #define LASAT_BMID_MASQUERADE2          0
117 #define LASAT_BMID_MASQUERADEPRO        1
118 #define LASAT_BMID_SAFEPIPE25           2
119 #define LASAT_BMID_SAFEPIPE50           3
120 #define LASAT_BMID_SAFEPIPE100          4
121 #define LASAT_BMID_SAFEPIPE5000         5
122 #define LASAT_BMID_SAFEPIPE7000         6
123 #define LASAT_BMID_SAFEPIPE1000         7
124 #if 0
125 #define LASAT_BMID_SAFEPIPE30           7
126 #define LASAT_BMID_SAFEPIPE5100         8
127 #define LASAT_BMID_SAFEPIPE7100         9
128 #endif
129 #define LASAT_BMID_UNKNOWN              0xf
130 #define LASAT_MAX_BMID_NAMES            9   /* no larger than 15! */
131
132 #define LASAT_HAS_EDHAC                 (1 << 0)
133 #define LASAT_EDHAC_FAST                (1 << 1)
134 #define LASAT_HAS_EADI                  (1 << 2)
135 #define LASAT_HAS_HIFN                  (1 << 3)
136 #define LASAT_HAS_ISDN                  (1 << 4)
137 #define LASAT_HAS_LEASEDLINE_IF         (1 << 5)
138 #define LASAT_HAS_HDC                   (1 << 6)
139
140 #define LASAT_PRID_MASQUERADE2          0
141 #define LASAT_PRID_MASQUERADEPRO        1
142 #define LASAT_PRID_SAFEPIPE25           2
143 #define LASAT_PRID_SAFEPIPE50           3
144 #define LASAT_PRID_SAFEPIPE100          4
145 #define LASAT_PRID_SAFEPIPE5000         5
146 #define LASAT_PRID_SAFEPIPE7000         6
147 #define LASAT_PRID_SAFEPIPE30           7
148 #define LASAT_PRID_SAFEPIPE5100         8
149 #define LASAT_PRID_SAFEPIPE7100         9
150
151 #define LASAT_PRID_SAFEPIPE1110         10
152 #define LASAT_PRID_SAFEPIPE3020         11
153 #define LASAT_PRID_SAFEPIPE3030         12
154 #define LASAT_PRID_SAFEPIPE5020         13
155 #define LASAT_PRID_SAFEPIPE5030         14
156 #define LASAT_PRID_SAFEPIPE1120         15
157 #define LASAT_PRID_SAFEPIPE1130         16
158 #define LASAT_PRID_SAFEPIPE6010         17
159 #define LASAT_PRID_SAFEPIPE6110         18
160 #define LASAT_PRID_SAFEPIPE6210         19
161 #define LASAT_PRID_SAFEPIPE1020         20
162 #define LASAT_PRID_SAFEPIPE1040         21
163 #define LASAT_PRID_SAFEPIPE1060         22
164
165 struct lasat_info {
166         unsigned int  li_cpu_hz;
167         unsigned int  li_bus_hz;
168         unsigned int  li_bmid;
169         unsigned int  li_memsize;
170         unsigned int  li_flash_size;
171         unsigned int  li_prid;
172         unsigned char li_bmstr[16];
173         unsigned char li_namestr[32];
174         unsigned char li_typestr[16];
175         /* Info on the Flash layout */
176         unsigned int  li_flash_base;
177         unsigned long li_flashpart_base[LASAT_MTD_LAST];
178         unsigned long li_flashpart_size[LASAT_MTD_LAST];
179         struct lasat_eeprom_struct li_eeprom_info;
180         unsigned int  li_eeprom_upgrade_version;
181         unsigned int  li_debugaccess;
182 };
183
184 extern struct lasat_info lasat_board_info;
185
186 static inline unsigned long lasat_flash_partition_start(int partno)
187 {
188         if (partno < 0 || partno >= LASAT_MTD_LAST)
189                 return 0;
190
191         return lasat_board_info.li_flashpart_base[partno];
192 }
193
194 static inline unsigned long lasat_flash_partition_size(int partno)
195 {
196         if (partno < 0 || partno >= LASAT_MTD_LAST)
197                 return 0;
198
199         return lasat_board_info.li_flashpart_size[partno];
200 }
201
202 /* Called from setup() to initialize the global board_info struct */
203 extern int lasat_init_board_info(void);
204
205 /* Write the modified EEPROM info struct */
206 extern void lasat_write_eeprom_info(void);
207
208 #define N_MACHTYPES             2
209 /* for calibration of delays */
210
211 /* the lasat_ndelay function is necessary because it is used at an
212  * early stage of the boot process where ndelay is not calibrated.
213  * It is used for the bit-banging rtc and eeprom drivers */
214
215 #include <linux/delay.h>
216 #include <linux/smp.h>
217
218 /* calculating with the slowest board with 100 MHz clock */
219 #define LASAT_100_DIVIDER 20
220 /* All 200's run at 250 MHz clock */
221 #define LASAT_200_DIVIDER 8
222
223 extern unsigned int lasat_ndelay_divider;
224
225 static inline void lasat_ndelay(unsigned int ns)
226 {
227         __delay(ns / lasat_ndelay_divider);
228 }
229
230 #define IS_LASAT_200()     (current_cpu_data.cputype == CPU_R5000)
231
232 #endif /* !defined (_LANGUAGE_ASSEMBLY) */
233
234 #define LASAT_SERVICEMODE_MAGIC_1     0xdeadbeef
235 #define LASAT_SERVICEMODE_MAGIC_2     0xfedeabba
236
237 /* Lasat 100 boards */
238 #define LASAT_GT_BASE           (KSEG1ADDR(0x14000000))
239
240 /* Lasat 200 boards */
241 #define Vrc5074_PHYS_BASE       0x1fa00000
242 #define Vrc5074_BASE            (KSEG1ADDR(Vrc5074_PHYS_BASE))
243 #define PCI_WINDOW1             0x1a000000
244
245 #endif /* _LASAT_H */