blob: 16c3eb164f4fe0cdb44b91eb3be271743b8beeb8 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * S390 version
Heiko Carstensa53c8fa2012-07-20 11:15:04 +02003 * Copyright IBM Corp. 1999
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
5 *
6 * Derived from "include/asm-i386/io.h"
7 */
8
9#ifndef _S390_IO_H
10#define _S390_IO_H
11
Jan Glaubercd248342012-11-29 12:50:30 +010012#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <asm/page.h>
Jan Glaubercd248342012-11-29 12:50:30 +010014#include <asm/pci_io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015
Linus Torvalds1da177e2005-04-16 15:20:36 -070016/*
17 * Change virtual addresses to physical addresses and vv.
18 * These are pretty trivial
19 */
Adrian Bunk4448aaf2005-11-08 21:34:42 -080020static inline unsigned long virt_to_phys(volatile void * address)
Linus Torvalds1da177e2005-04-16 15:20:36 -070021{
22 unsigned long real_address;
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020023 asm volatile(
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020024 " lra %0,0(%1)\n"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020025 " jz 0f\n"
26 " la %0,0\n"
Jan Glaubercd248342012-11-29 12:50:30 +010027 "0:"
Martin Schwidefsky94c12cc2006-09-28 16:56:43 +020028 : "=a" (real_address) : "a" (address) : "cc");
Jan Glaubercd248342012-11-29 12:50:30 +010029 return real_address;
Linus Torvalds1da177e2005-04-16 15:20:36 -070030}
Jan Glaubercd248342012-11-29 12:50:30 +010031#define virt_to_phys virt_to_phys
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
Adrian Bunk4448aaf2005-11-08 21:34:42 -080033static inline void * phys_to_virt(unsigned long address)
Linus Torvalds1da177e2005-04-16 15:20:36 -070034{
Martin Schwidefsky022ae412007-02-12 15:49:57 +010035 return (void *) address;
Linus Torvalds1da177e2005-04-16 15:20:36 -070036}
37
Michael Holzheub2a68c22012-05-09 16:27:36 +020038void *xlate_dev_mem_ptr(unsigned long phys);
39void unxlate_dev_mem_ptr(unsigned long phys, void *addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41/*
42 * Convert a virtual cached pointer to an uncached pointer
43 */
44#define xlate_dev_kmem_ptr(p) p
45
Jan Glaubercd248342012-11-29 12:50:30 +010046#define IO_SPACE_LIMIT 0
47
48#ifdef CONFIG_PCI
49
50#define ioremap_nocache(addr, size) ioremap(addr, size)
51#define ioremap_wc ioremap_nocache
52
53/* TODO: s390 cannot support io_remap_pfn_range... */
54#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
55 remap_pfn_range(vma, vaddr, pfn, size, prot)
56
57static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
58{
59 return (void __iomem *) offset;
60}
61
62static inline void iounmap(volatile void __iomem *addr)
63{
64}
65
66/*
67 * s390 needs a private implementation of pci_iomap since ioremap with its
68 * offset parameter isn't sufficient. That's because BAR spaces are not
69 * disjunctive on s390 so we need the bar parameter of pci_iomap to find
70 * the corresponding device and create the mapping cookie.
71 */
72#define pci_iomap pci_iomap
73#define pci_iounmap pci_iounmap
74
75#define memcpy_fromio(dst, src, count) zpci_memcpy_fromio(dst, src, count)
76#define memcpy_toio(dst, src, count) zpci_memcpy_toio(dst, src, count)
77#define memset_io(dst, val, count) zpci_memset_io(dst, val, count)
78
79#define __raw_readb zpci_read_u8
80#define __raw_readw zpci_read_u16
81#define __raw_readl zpci_read_u32
82#define __raw_readq zpci_read_u64
83#define __raw_writeb zpci_write_u8
84#define __raw_writew zpci_write_u16
85#define __raw_writel zpci_write_u32
86#define __raw_writeq zpci_write_u64
87
88#endif /* CONFIG_PCI */
89
90#include <asm-generic/io.h>
91
Linus Torvalds1da177e2005-04-16 15:20:36 -070092#endif