TCP: Fix and simplify microsecond rtt sampling
[linux/fpc-iii.git] / include / asm-ppc / mv64x60.h
blob4f2405b8361206550792e46b256df558c7130b69
1 /*
2 * include/asm-ppc/mv64x60.h
4 * Prototypes, etc. for the Marvell/Galileo MV64x60 host bridge routines.
6 * Author: Mark A. Greer <mgreer@mvista.com>
8 * 2001-2002 (c) MontaVista, Software, Inc. This file is licensed under
9 * the terms of the GNU General Public License version 2. This program
10 * is licensed "as is" without any warranty of any kind, whether express
11 * or implied.
13 #ifndef __ASMPPC_MV64x60_H
14 #define __ASMPPC_MV64x60_H
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/pci.h>
19 #include <linux/slab.h>
20 #include <linux/config.h>
22 #include <asm/byteorder.h>
23 #include <asm/io.h>
24 #include <asm/irq.h>
25 #include <asm/uaccess.h>
26 #include <asm/machdep.h>
27 #include <asm/pci-bridge.h>
28 #include <asm/mv64x60_defs.h>
30 struct platform_device;
32 extern u8 mv64x60_pci_exclude_bridge;
34 extern spinlock_t mv64x60_lock;
36 /* 32-bit Window table entry defines */
37 #define MV64x60_CPU2MEM_0_WIN 0
38 #define MV64x60_CPU2MEM_1_WIN 1
39 #define MV64x60_CPU2MEM_2_WIN 2
40 #define MV64x60_CPU2MEM_3_WIN 3
41 #define MV64x60_CPU2DEV_0_WIN 4
42 #define MV64x60_CPU2DEV_1_WIN 5
43 #define MV64x60_CPU2DEV_2_WIN 6
44 #define MV64x60_CPU2DEV_3_WIN 7
45 #define MV64x60_CPU2BOOT_WIN 8
46 #define MV64x60_CPU2PCI0_IO_WIN 9
47 #define MV64x60_CPU2PCI0_MEM_0_WIN 10
48 #define MV64x60_CPU2PCI0_MEM_1_WIN 11
49 #define MV64x60_CPU2PCI0_MEM_2_WIN 12
50 #define MV64x60_CPU2PCI0_MEM_3_WIN 13
51 #define MV64x60_CPU2PCI1_IO_WIN 14
52 #define MV64x60_CPU2PCI1_MEM_0_WIN 15
53 #define MV64x60_CPU2PCI1_MEM_1_WIN 16
54 #define MV64x60_CPU2PCI1_MEM_2_WIN 17
55 #define MV64x60_CPU2PCI1_MEM_3_WIN 18
56 #define MV64x60_CPU2SRAM_WIN 19
57 #define MV64x60_CPU2PCI0_IO_REMAP_WIN 20
58 #define MV64x60_CPU2PCI1_IO_REMAP_WIN 21
59 #define MV64x60_CPU_PROT_0_WIN 22
60 #define MV64x60_CPU_PROT_1_WIN 23
61 #define MV64x60_CPU_PROT_2_WIN 24
62 #define MV64x60_CPU_PROT_3_WIN 25
63 #define MV64x60_CPU_SNOOP_0_WIN 26
64 #define MV64x60_CPU_SNOOP_1_WIN 27
65 #define MV64x60_CPU_SNOOP_2_WIN 28
66 #define MV64x60_CPU_SNOOP_3_WIN 29
67 #define MV64x60_PCI02MEM_REMAP_0_WIN 30
68 #define MV64x60_PCI02MEM_REMAP_1_WIN 31
69 #define MV64x60_PCI02MEM_REMAP_2_WIN 32
70 #define MV64x60_PCI02MEM_REMAP_3_WIN 33
71 #define MV64x60_PCI12MEM_REMAP_0_WIN 34
72 #define MV64x60_PCI12MEM_REMAP_1_WIN 35
73 #define MV64x60_PCI12MEM_REMAP_2_WIN 36
74 #define MV64x60_PCI12MEM_REMAP_3_WIN 37
75 #define MV64x60_ENET2MEM_0_WIN 38
76 #define MV64x60_ENET2MEM_1_WIN 39
77 #define MV64x60_ENET2MEM_2_WIN 40
78 #define MV64x60_ENET2MEM_3_WIN 41
79 #define MV64x60_ENET2MEM_4_WIN 42
80 #define MV64x60_ENET2MEM_5_WIN 43
81 #define MV64x60_MPSC2MEM_0_WIN 44
82 #define MV64x60_MPSC2MEM_1_WIN 45
83 #define MV64x60_MPSC2MEM_2_WIN 46
84 #define MV64x60_MPSC2MEM_3_WIN 47
85 #define MV64x60_IDMA2MEM_0_WIN 48
86 #define MV64x60_IDMA2MEM_1_WIN 49
87 #define MV64x60_IDMA2MEM_2_WIN 50
88 #define MV64x60_IDMA2MEM_3_WIN 51
89 #define MV64x60_IDMA2MEM_4_WIN 52
90 #define MV64x60_IDMA2MEM_5_WIN 53
91 #define MV64x60_IDMA2MEM_6_WIN 54
92 #define MV64x60_IDMA2MEM_7_WIN 55
94 #define MV64x60_32BIT_WIN_COUNT 56
96 /* 64-bit Window table entry defines */
97 #define MV64x60_CPU2PCI0_MEM_0_REMAP_WIN 0
98 #define MV64x60_CPU2PCI0_MEM_1_REMAP_WIN 1
99 #define MV64x60_CPU2PCI0_MEM_2_REMAP_WIN 2
100 #define MV64x60_CPU2PCI0_MEM_3_REMAP_WIN 3
101 #define MV64x60_CPU2PCI1_MEM_0_REMAP_WIN 4
102 #define MV64x60_CPU2PCI1_MEM_1_REMAP_WIN 5
103 #define MV64x60_CPU2PCI1_MEM_2_REMAP_WIN 6
104 #define MV64x60_CPU2PCI1_MEM_3_REMAP_WIN 7
105 #define MV64x60_PCI02MEM_ACC_CNTL_0_WIN 8
106 #define MV64x60_PCI02MEM_ACC_CNTL_1_WIN 9
107 #define MV64x60_PCI02MEM_ACC_CNTL_2_WIN 10
108 #define MV64x60_PCI02MEM_ACC_CNTL_3_WIN 11
109 #define MV64x60_PCI12MEM_ACC_CNTL_0_WIN 12
110 #define MV64x60_PCI12MEM_ACC_CNTL_1_WIN 13
111 #define MV64x60_PCI12MEM_ACC_CNTL_2_WIN 14
112 #define MV64x60_PCI12MEM_ACC_CNTL_3_WIN 15
113 #define MV64x60_PCI02MEM_SNOOP_0_WIN 16
114 #define MV64x60_PCI02MEM_SNOOP_1_WIN 17
115 #define MV64x60_PCI02MEM_SNOOP_2_WIN 18
116 #define MV64x60_PCI02MEM_SNOOP_3_WIN 19
117 #define MV64x60_PCI12MEM_SNOOP_0_WIN 20
118 #define MV64x60_PCI12MEM_SNOOP_1_WIN 21
119 #define MV64x60_PCI12MEM_SNOOP_2_WIN 22
120 #define MV64x60_PCI12MEM_SNOOP_3_WIN 23
122 #define MV64x60_64BIT_WIN_COUNT 24
124 /* Watchdog Platform Device, Driver Data */
125 #define MV64x60_WDT_NAME "wdt"
127 struct mv64x60_wdt_pdata {
128 int timeout; /* watchdog expiry in seconds, default 10 */
129 int bus_clk; /* bus clock in MHz, default 133 */
133 * Define a structure that's used to pass in config information to the
134 * core routines.
136 struct mv64x60_pci_window {
137 u32 cpu_base;
138 u32 pci_base_hi;
139 u32 pci_base_lo;
140 u32 size;
141 u32 swap;
144 struct mv64x60_pci_info {
145 u8 enable_bus; /* allow access to this PCI bus? */
147 struct mv64x60_pci_window pci_io;
148 struct mv64x60_pci_window pci_mem[3];
150 u32 acc_cntl_options[MV64x60_CPU2MEM_WINDOWS];
151 u32 snoop_options[MV64x60_CPU2MEM_WINDOWS];
152 u16 pci_cmd_bits;
153 u16 latency_timer;
156 struct mv64x60_setup_info {
157 u32 phys_reg_base;
158 u32 window_preserve_mask_32_hi;
159 u32 window_preserve_mask_32_lo;
160 u32 window_preserve_mask_64;
162 u32 cpu_prot_options[MV64x60_CPU2MEM_WINDOWS];
163 u32 cpu_snoop_options[MV64x60_CPU2MEM_WINDOWS];
164 u32 enet_options[MV64x60_CPU2MEM_WINDOWS];
165 u32 mpsc_options[MV64x60_CPU2MEM_WINDOWS];
166 u32 idma_options[MV64x60_CPU2MEM_WINDOWS];
168 struct mv64x60_pci_info pci_0;
169 struct mv64x60_pci_info pci_1;
172 /* Define what the top bits in the extra member of a window entry means. */
173 #define MV64x60_EXTRA_INVALID 0x00000000
174 #define MV64x60_EXTRA_CPUWIN_ENAB 0x10000000
175 #define MV64x60_EXTRA_CPUPROT_ENAB 0x20000000
176 #define MV64x60_EXTRA_ENET_ENAB 0x30000000
177 #define MV64x60_EXTRA_MPSC_ENAB 0x40000000
178 #define MV64x60_EXTRA_IDMA_ENAB 0x50000000
179 #define MV64x60_EXTRA_PCIACC_ENAB 0x60000000
181 #define MV64x60_EXTRA_MASK 0xf0000000
184 * Define the 'handle' struct that will be passed between the 64x60 core
185 * code and the platform-specific code that will use it. The handle
186 * will contain pointers to chip-specific routines & information.
188 struct mv64x60_32bit_window {
189 u32 base_reg;
190 u32 size_reg;
191 u8 base_bits;
192 u8 size_bits;
193 u32 (*get_from_field)(u32 val, u32 num_bits);
194 u32 (*map_to_field)(u32 val, u32 num_bits);
195 u32 extra;
198 struct mv64x60_64bit_window {
199 u32 base_hi_reg;
200 u32 base_lo_reg;
201 u32 size_reg;
202 u8 base_lo_bits;
203 u8 size_bits;
204 u32 (*get_from_field)(u32 val, u32 num_bits);
205 u32 (*map_to_field)(u32 val, u32 num_bits);
206 u32 extra;
209 typedef struct mv64x60_handle mv64x60_handle_t;
210 struct mv64x60_chip_info {
211 u32 (*translate_size)(u32 base, u32 size, u32 num_bits);
212 u32 (*untranslate_size)(u32 base, u32 size, u32 num_bits);
213 void (*set_pci2mem_window)(struct pci_controller *hose, u32 bus,
214 u32 window, u32 base);
215 void (*set_pci2regs_window)(struct mv64x60_handle *bh,
216 struct pci_controller *hose, u32 bus, u32 base);
217 u32 (*is_enabled_32bit)(mv64x60_handle_t *bh, u32 window);
218 void (*enable_window_32bit)(mv64x60_handle_t *bh, u32 window);
219 void (*disable_window_32bit)(mv64x60_handle_t *bh, u32 window);
220 void (*enable_window_64bit)(mv64x60_handle_t *bh, u32 window);
221 void (*disable_window_64bit)(mv64x60_handle_t *bh, u32 window);
222 void (*disable_all_windows)(mv64x60_handle_t *bh,
223 struct mv64x60_setup_info *si);
224 void (*config_io2mem_windows)(mv64x60_handle_t *bh,
225 struct mv64x60_setup_info *si,
226 u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2]);
227 void (*set_mpsc2regs_window)(struct mv64x60_handle *bh, u32 base);
228 void (*chip_specific_init)(mv64x60_handle_t *bh,
229 struct mv64x60_setup_info *si);
231 struct mv64x60_32bit_window *window_tab_32bit;
232 struct mv64x60_64bit_window *window_tab_64bit;
235 struct mv64x60_handle {
236 u32 type; /* type of bridge */
237 u32 rev; /* revision of bridge */
238 void __iomem *v_base;/* virtual base addr of bridge regs */
239 phys_addr_t p_base; /* physical base addr of bridge regs */
241 u32 pci_mode_a; /* pci 0 mode: conventional pci, pci-x*/
242 u32 pci_mode_b; /* pci 1 mode: conventional pci, pci-x*/
244 u32 io_base_a; /* vaddr of pci 0's I/O space */
245 u32 io_base_b; /* vaddr of pci 1's I/O space */
247 struct pci_controller *hose_a;
248 struct pci_controller *hose_b;
250 struct mv64x60_chip_info *ci; /* chip/bridge-specific info */
254 /* Define I/O routines for accessing registers on the 64x60 bridge. */
255 extern inline void
256 mv64x60_write(struct mv64x60_handle *bh, u32 offset, u32 val) {
257 ulong flags;
259 spin_lock_irqsave(&mv64x60_lock, flags);
260 out_le32(bh->v_base + offset, val);
261 spin_unlock_irqrestore(&mv64x60_lock, flags);
264 extern inline u32
265 mv64x60_read(struct mv64x60_handle *bh, u32 offset) {
266 ulong flags;
267 u32 reg;
269 spin_lock_irqsave(&mv64x60_lock, flags);
270 reg = in_le32(bh->v_base + offset);
271 spin_unlock_irqrestore(&mv64x60_lock, flags);
272 return reg;
275 extern inline void
276 mv64x60_modify(struct mv64x60_handle *bh, u32 offs, u32 data, u32 mask)
278 u32 reg;
279 ulong flags;
281 spin_lock_irqsave(&mv64x60_lock, flags);
282 reg = in_le32(bh->v_base + offs) & (~mask);
283 reg |= data & mask;
284 out_le32(bh->v_base + offs, reg);
285 spin_unlock_irqrestore(&mv64x60_lock, flags);
288 #define mv64x60_set_bits(bh, offs, bits) mv64x60_modify(bh, offs, ~0, bits)
289 #define mv64x60_clr_bits(bh, offs, bits) mv64x60_modify(bh, offs, 0, bits)
291 #if defined(CONFIG_SYSFS) && !defined(CONFIG_GT64260)
292 #define MV64XXX_DEV_NAME "mv64xxx"
294 struct mv64xxx_pdata {
295 u32 hs_reg_valid;
297 #endif
299 /* Externally visible function prototypes */
300 int mv64x60_init(struct mv64x60_handle *bh, struct mv64x60_setup_info *si);
301 u32 mv64x60_get_mem_size(u32 bridge_base, u32 chip_type);
302 void mv64x60_early_init(struct mv64x60_handle *bh,
303 struct mv64x60_setup_info *si);
304 void mv64x60_alloc_hose(struct mv64x60_handle *bh, u32 cfg_addr,
305 u32 cfg_data, struct pci_controller **hose);
306 int mv64x60_get_type(struct mv64x60_handle *bh);
307 int mv64x60_setup_for_chip(struct mv64x60_handle *bh);
308 void __iomem *mv64x60_get_bridge_vbase(void);
309 u32 mv64x60_get_bridge_type(void);
310 u32 mv64x60_get_bridge_rev(void);
311 void mv64x60_get_mem_windows(struct mv64x60_handle *bh,
312 u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2]);
313 void mv64x60_config_cpu2mem_windows(struct mv64x60_handle *bh,
314 struct mv64x60_setup_info *si,
315 u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2]);
316 void mv64x60_config_cpu2pci_windows(struct mv64x60_handle *bh,
317 struct mv64x60_pci_info *pi, u32 bus);
318 void mv64x60_config_pci2mem_windows(struct mv64x60_handle *bh,
319 struct pci_controller *hose, struct mv64x60_pci_info *pi, u32 bus,
320 u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2]);
321 void mv64x60_config_resources(struct pci_controller *hose,
322 struct mv64x60_pci_info *pi, u32 io_base);
323 void mv64x60_config_pci_params(struct pci_controller *hose,
324 struct mv64x60_pci_info *pi);
325 void mv64x60_pd_fixup(struct mv64x60_handle *bh,
326 struct platform_device *pd_devs[], u32 entries);
327 void mv64x60_get_32bit_window(struct mv64x60_handle *bh, u32 window,
328 u32 *base, u32 *size);
329 void mv64x60_set_32bit_window(struct mv64x60_handle *bh, u32 window, u32 base,
330 u32 size, u32 other_bits);
331 void mv64x60_get_64bit_window(struct mv64x60_handle *bh, u32 window,
332 u32 *base_hi, u32 *base_lo, u32 *size);
333 void mv64x60_set_64bit_window(struct mv64x60_handle *bh, u32 window,
334 u32 base_hi, u32 base_lo, u32 size, u32 other_bits);
335 void mv64x60_set_bus(struct mv64x60_handle *bh, u32 bus, u32 child_bus);
336 int mv64x60_pci_exclude_device(u8 bus, u8 devfn);
339 void gt64260_init_irq(void);
340 int gt64260_get_irq(struct pt_regs *regs);
341 void mv64360_init_irq(void);
342 int mv64360_get_irq(struct pt_regs *regs);
344 u32 mv64x60_mask(u32 val, u32 num_bits);
345 u32 mv64x60_shift_left(u32 val, u32 num_bits);
346 u32 mv64x60_shift_right(u32 val, u32 num_bits);
347 u32 mv64x60_calc_mem_size(struct mv64x60_handle *bh,
348 u32 mem_windows[MV64x60_CPU2MEM_WINDOWS][2]);
350 void mv64x60_progress_init(u32 base);
351 void mv64x60_mpsc_progress(char *s, unsigned short hex);
353 extern struct mv64x60_32bit_window
354 gt64260_32bit_windows[MV64x60_32BIT_WIN_COUNT];
355 extern struct mv64x60_64bit_window
356 gt64260_64bit_windows[MV64x60_64BIT_WIN_COUNT];
357 extern struct mv64x60_32bit_window
358 mv64360_32bit_windows[MV64x60_32BIT_WIN_COUNT];
359 extern struct mv64x60_64bit_window
360 mv64360_64bit_windows[MV64x60_64BIT_WIN_COUNT];
362 #endif /* __ASMPPC_MV64x60_H */