1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
/* $OpenBSD: xbow.h,v 1.4 2009/06/13 21:48:03 miod Exp $ */
/*
* Copyright (c) 2008 Miodrag Vallat.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _XBOW_H_
#define _XBOW_H_
/*
* Devices connected to the XBow are called ``widgets'' and are
* identified by a common widget memory area at the beginning of their
* memory space.
*
* Each widget has its own memory space, upon which windows of different
* sizes can be defined. OpenBSD only cares about the shortest window
* (which fits in 32 bits of address space), and the longest window (which
* provides access to the complete widget space).
*
* Apart from the crossbow itself being widget #0, the widgets are divided
* in two groups: widgets #8 to #b are the ``upper'' widgets, while widgets
* #c to #f are the ``lower'' widgets.
*
* Widgets are uniquely identified with their widget number on the XBow
* bus. However, the way they are mapped and accessed will depend on the
* processor (well, the processor board node) requesting access. Hence the
* two parameters needed to map a widget.
*/
extern paddr_t (*xbow_widget_short)(int16_t, u_int);
extern paddr_t (*xbow_widget_long)(int16_t, u_int);
extern unsigned int xbow_long_shift;
extern int (*xbow_widget_id)(int16_t, u_int, uint32_t *);
extern int xbow_intr_widget;
extern paddr_t xbow_intr_widget_register;
extern int (*xbow_intr_widget_intr_register)(int, int, int *);
extern int (*xbow_intr_widget_intr_establish)(int (*)(void *), void *,
int, int, const char *);
extern void (*xbow_intr_widget_intr_disestablish)(int);
/*
* Common Widget Registers. Every widget provides them.
*/
/* all registers are 32 bits within big-endian 64 bit blocks */
#define WIDGET_ID 0x0004
#define WIDGET_ID_REV_MASK 0xf0000000
#define WIDGET_ID_REV_SHIFT 28
#define WIDGET_ID_PRODUCT_MASK 0x0ffff000
#define WIDGET_ID_PRODUCT_SHIFT 12
#define WIDGET_ID_VENDOR_MASK 0x00000ffe
#define WIDGET_ID_VENDOR_SHIFT 1
#define WIDGET_STATUS 0x000c
#define WIDGET_ERR_ADDR_UPPER 0x0014
#define WIDGET_ERR_ADDR_LOWER 0x001c
#define WIDGET_CONTROL 0x0024
#define WIDGET_REQ_TIMEOUT 0x002c
#define WIDGET_INTDEST_ADDR_UPPER 0x0034
#define WIDGET_INTDEST_ADDR_LOWER 0x003c
#define WIDGET_ERR_CMD_WORD 0x0044
#define WIDGET_LLP_CFG 0x004c
#define WIDGET_TFLUSH 0x0054
/*
* Crossbow Specific Registers.
*/
#define XBOW_WID_ARB_RELOAD 0x005c
#define XBOW_PERFCNTR_A 0x0064
#define XBOW_PERFCNTR_B 0x006c
#define XBOW_NIC 0x0074
#define XBOW_WIDGET_LINK(w) (0x0100 + ((w) & 7) * 0x0040)
/*
* Per-widget ``Link'' Register Set.
*/
#define WIDGET_LINK_IBF 0x0004
#define WIDGET_LINK_CONTROL 0x000c
#define WIDGET_CONTROL_ALIVE 0x80000000
#define WIDGET_LINK_STATUS 0x0014
#define WIDGET_STATUS_ALIVE 0x80000000
#define WIDGET_LINK_ARB_UPPER 0x001c
#define WIDGET_LINK_ARB_LOWER 0x0024
#define WIDGET_LINK_STATUS_CLEAR 0x002c
#define WIDGET_LINK_RESET 0x0034
#define WIDGET_LINK_AUX_STATUS 0x003c
/*
* Valid widget values
*/
#define WIDGET_MIN 8
#define WIDGET_MAX 15
struct xbow_attach_args {
int16_t xaa_nasid;
int xaa_widget;
uint32_t xaa_vendor;
uint32_t xaa_product;
uint32_t xaa_revision;
bus_space_tag_t xaa_short_tag;
bus_space_tag_t xaa_long_tag;
};
void xbow_build_bus_space(struct mips_bus_space *, int, int, int);
int xbow_intr_register(int, int, int *);
int xbow_intr_establish(int (*)(void *), void *, int, int, const char *);
void xbow_intr_disestablish(int);
int xbow_space_map_short(bus_space_tag_t, bus_addr_t, bus_size_t, int,
bus_space_handle_t *);
uint8_t xbow_read_1(bus_space_tag_t, bus_space_handle_t, bus_size_t);
uint16_t xbow_read_2(bus_space_tag_t, bus_space_handle_t, bus_size_t);
void xbow_write_1(bus_space_tag_t, bus_space_handle_t, bus_size_t, uint8_t);
void xbow_write_2(bus_space_tag_t, bus_space_handle_t, bus_size_t,
uint16_t);
#endif /* _XBOW_H_ */
|