/*1* This file is subject to the terms and conditions of the GNU General Public2* License. See the file "COPYING" in the main directory of this archive3* for more details.4*5* Copyright (C) 2000-2003, 2006 Silicon Graphics, Inc. All rights reserved.6*/78#include <linux/module.h>9#include <linux/acpi.h>10#include <asm/io.h>11#include <asm/delay.h>12#include <asm/vga.h>13#include <asm/sn/nodepda.h>14#include <asm/sn/simulator.h>15#include <asm/sn/pda.h>16#include <asm/sn/sn_cpuid.h>17#include <asm/sn/shub_mmr.h>18#include <asm/sn/acpi.h>1920#define IS_LEGACY_VGA_IOPORT(p) \21(((p) >= 0x3b0 && (p) <= 0x3bb) || ((p) >= 0x3c0 && (p) <= 0x3df))2223/**24* sn_io_addr - convert an in/out port to an i/o address25* @port: port to convert26*27* Legacy in/out instructions are converted to ld/st instructions28* on IA64. This routine will convert a port number into a valid29* SN i/o address. Used by sn_in*() and sn_out*().30*/3132void *sn_io_addr(unsigned long port)33{34if (!IS_RUNNING_ON_SIMULATOR()) {35if (IS_LEGACY_VGA_IOPORT(port))36return (__ia64_mk_io_addr(port));37/* On sn2, legacy I/O ports don't point at anything */38if (port < (64 * 1024))39return NULL;40if (SN_ACPI_BASE_SUPPORT())41return (__ia64_mk_io_addr(port));42else43return ((void *)(port | __IA64_UNCACHED_OFFSET));44} else {45/* but the simulator uses them... */46unsigned long addr;4748/*49* word align port, but need more than 10 bits50* for accessing registers in bedrock local block51* (so we don't do port&0xfff)52*/53addr = (is_shub2() ? 0xc00000028c000000UL : 0xc0000087cc000000UL) | ((port >> 2) << 12);54if ((port >= 0x1f0 && port <= 0x1f7) || port == 0x3f6 || port == 0x3f7)55addr |= port;56return (void *)addr;57}58}5960EXPORT_SYMBOL(sn_io_addr);6162/**63* __sn_mmiowb - I/O space memory barrier64*65* See arch/ia64/include/asm/io.h and Documentation/DocBook/deviceiobook.tmpl66* for details.67*68* On SN2, we wait for the PIO_WRITE_STATUS SHub register to clear.69* See PV 871084 for details about the WAR about zero value.70*71*/72void __sn_mmiowb(void)73{74volatile unsigned long *adr = pda->pio_write_status_addr;75unsigned long val = pda->pio_write_status_val;7677while ((*adr & SH_PIO_WRITE_STATUS_PENDING_WRITE_COUNT_MASK) != val)78cpu_relax();79}8081EXPORT_SYMBOL(__sn_mmiowb);828384