2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 2000-2003 Silicon Graphics, Inc. All rights reserved.
9 #include <linux/module.h>
11 #include <asm/delay.h>
12 #include <asm/sn/nodepda.h>
13 #include <asm/sn/simulator.h>
14 #include <asm/sn/pda.h>
15 #include <asm/sn/sn_cpuid.h>
16 #include <asm/sn/shub_mmr.h>
19 * sn_io_addr - convert an in/out port to an i/o address
20 * @port: port to convert
22 * Legacy in/out instructions are converted to ld/st instructions
23 * on IA64. This routine will convert a port number into a valid
24 * SN i/o address. Used by sn_in*() and sn_out*().
26 void *sn_io_addr(unsigned long port)
28 if (!IS_RUNNING_ON_SIMULATOR()) {
29 /* On sn2, legacy I/O ports don't point at anything */
30 if (port < (64 * 1024))
32 return ((void *)(port | __IA64_UNCACHED_OFFSET));
34 /* but the simulator uses them... */
35 unsigned long io_base;
39 * word align port, but need more than 10 bits
40 * for accessing registers in bedrock local block
41 * (so we don't do port&0xfff)
43 if ((port >= 0x1f0 && port <= 0x1f7) ||
44 port == 0x3f6 || port == 0x3f7) {
45 io_base = (0xc000000fcc000000UL |
46 ((unsigned long)get_nasid() << 38));
47 addr = io_base | ((port >> 2) << 12) | (port & 0xfff);
49 addr = __ia64_get_io_port_base() | ((port >> 2) << 2);
55 EXPORT_SYMBOL(sn_io_addr);
58 * __sn_mmiowb - I/O space memory barrier
60 * See include/asm-ia64/io.h and Documentation/DocBook/deviceiobook.tmpl
63 * On SN2, we wait for the PIO_WRITE_STATUS SHub register to clear.
64 * See PV 871084 for details about the WAR about zero value.
67 void __sn_mmiowb(void)
69 while ((((volatile unsigned long)(*pda->pio_write_status_addr)) &
70 SH_PIO_WRITE_STATUS_0_PENDING_WRITE_COUNT_MASK) !=
71 SH_PIO_WRITE_STATUS_0_PENDING_WRITE_COUNT_MASK)
75 EXPORT_SYMBOL(__sn_mmiowb);