1633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham/*
2633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham * This file is subject to the terms and conditions of the GNU General Public
3633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham * License.  See the file "COPYING" in the main directory of this archive
4633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham * for more details.
5633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham *
6633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham * Copyright (C) 2000, 2003 Ralf Baechle
7633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham * Copyright (C) 2000 Silicon Graphics, Inc.
8633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham */
9633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#ifndef _ASM_SN_IO_H
10633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#define _ASM_SN_IO_H
11633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham
12633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#if defined(CONFIG_SGI_IP27)
13633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#include <asm/sn/sn0/hubio.h>
14633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#endif
15633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham
16633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham
17633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#define IIO_ITTE_BASE		0x400160 /* base of translation table entries */
18633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#define IIO_ITTE(bigwin)	(IIO_ITTE_BASE + 8*(bigwin))
19633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham
20633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#define IIO_ITTE_OFFSET_BITS	5	/* size of offset field */
21633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#define IIO_ITTE_OFFSET_MASK	((1<<IIO_ITTE_OFFSET_BITS)-1)
22633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#define IIO_ITTE_OFFSET_SHIFT	0
23633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham
24633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#define IIO_ITTE_WIDGET_BITS	4	/* size of widget field */
25633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#define IIO_ITTE_WIDGET_MASK	((1<<IIO_ITTE_WIDGET_BITS)-1)
26633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#define IIO_ITTE_WIDGET_SHIFT	8
27633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham
28633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#define IIO_ITTE_IOSP		1	/* I/O Space bit */
29633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#define IIO_ITTE_IOSP_MASK	1
30633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#define IIO_ITTE_IOSP_SHIFT	12
31633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#define HUB_PIO_MAP_TO_MEM	0
32633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#define HUB_PIO_MAP_TO_IO	1
33633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham
34633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#define IIO_ITTE_INVALID_WIDGET	3	/* an invalid widget  */
35633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham
36633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#define IIO_ITTE_PUT(nasid, bigwin, io_or_mem, widget, addr) \
37633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham	REMOTE_HUB_S((nasid), IIO_ITTE(bigwin), \
38633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham		(((((addr) >> BWIN_SIZE_BITS) & \
39633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham		   IIO_ITTE_OFFSET_MASK) << IIO_ITTE_OFFSET_SHIFT) | \
40633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham		(io_or_mem << IIO_ITTE_IOSP_SHIFT) | \
41633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham		(((widget) & IIO_ITTE_WIDGET_MASK) << IIO_ITTE_WIDGET_SHIFT)))
42633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham
43633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#define IIO_ITTE_DISABLE(nasid, bigwin) \
44633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham	IIO_ITTE_PUT((nasid), HUB_PIO_MAP_TO_MEM, \
45633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham		     (bigwin), IIO_ITTE_INVALID_WIDGET, 0)
46633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham
47633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#define IIO_ITTE_GET(nasid, bigwin) REMOTE_HUB_ADDR((nasid), IIO_ITTE(bigwin))
48633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham
49633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham/*
50633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham * Macro which takes the widget number, and returns the
51633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham * IO PRB address of that widget.
52633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham * value _x is expected to be a widget number in the range
53633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham * 0, 8 - 0xF
54633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham */
55633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#define	IIO_IOPRB(_x)	(IIO_IOPRB_0 + ( ( (_x) < HUB_WIDGET_ID_MIN ? \
56633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham			(_x) : \
57633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham			(_x) - (HUB_WIDGET_ID_MIN-1)) << 3) )
58633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham
59633c3473533ad9f2cca069b22cc5d95cd4e3510bRaghu Gandham#endif /* _ASM_SN_IO_H */
60