]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - include/linux/libio.h
UBUNTU: SAUCE: Import aufs driver
[mirror_ubuntu-artful-kernel.git] / include / linux / libio.h
1 /*
2 * Copyright (C) 2017 Hisilicon Limited, All Rights Reserved.
3 * Author: Zhichang Yuan <yuanzhichang@hisilicon.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef __LINUX_LIBIO_H
19 #define __LINUX_LIBIO_H
20
21 #ifdef __KERNEL__
22
23 #include <linux/device.h>
24 #include <linux/fwnode.h>
25
26 /* This is compatible to PCI MMIO. */
27 #define IO_CPU_MMIO 0x01
28 /* All hosts where there are no CPU addr */
29 #define IO_HOST_INDIRECT 0x02
30
31 struct libio_range {
32 struct list_head list;
33 struct fwnode_handle *node;
34 resource_size_t size; /* range size populated */
35 resource_size_t io_start; /* logical pio start. inclusive */
36 resource_size_t hw_start;
37 unsigned long flags;
38 void *devpara; /* private parameter of the host device */
39 struct libio_ops *ops; /* ops operating on this node */
40 };
41
42 struct libio_ops {
43 u32 (*pfin)(void *devobj, unsigned long ptaddr, size_t dlen);
44 void (*pfout)(void *devobj, unsigned long ptaddr, u32 outval,
45 size_t dlen);
46 u32 (*pfins)(void *devobj, unsigned long ptaddr, void *inbuf,
47 size_t dlen, unsigned int count);
48 void (*pfouts)(void *devobj, unsigned long ptaddr,
49 const void *outbuf, size_t dlen, unsigned int count);
50 };
51
52 extern u8 libio_inb(unsigned long addr);
53 extern void libio_outb(u8 value, unsigned long addr);
54 extern void libio_outw(u16 value, unsigned long addr);
55 extern void libio_outl(u32 value, unsigned long addr);
56 extern u16 libio_inw(unsigned long addr);
57 extern u32 libio_inl(unsigned long addr);
58 extern void libio_outb(u8 value, unsigned long addr);
59 extern void libio_outw(u16 value, unsigned long addr);
60 extern void libio_outl(u32 value, unsigned long addr);
61 extern void libio_insb(unsigned long addr, void *buffer, unsigned int count);
62 extern void libio_insl(unsigned long addr, void *buffer, unsigned int count);
63 extern void libio_insw(unsigned long addr, void *buffer, unsigned int count);
64 extern void libio_outsb(unsigned long addr, const void *buffer,
65 unsigned int count);
66 extern void libio_outsw(unsigned long addr, const void *buffer,
67 unsigned int count);
68 extern void libio_outsl(unsigned long addr, const void *buffer,
69 unsigned int count);
70 #ifdef CONFIG_LIBIO
71 extern struct libio_range
72 *find_io_range_from_fwnode(struct fwnode_handle *fwnode);
73 extern unsigned long libio_translate_hwaddr(struct fwnode_handle *fwnode,
74 resource_size_t hw_addr);
75 extern struct libio_range *register_libio_range(struct libio_range *newrange);
76 extern resource_size_t libio_to_hwaddr(unsigned long pio);
77
78 extern unsigned long libio_translate_cpuaddr(resource_size_t hw_addr);
79 #else
80 static inline struct libio_range
81 *find_io_range_from_fwnode(struct fwnode_handle *fwnode)
82 {
83 return NULL;
84 }
85
86 static inline unsigned long libio_translate_hwaddr(struct fwnode_handle *fwnode,
87 resource_size_t hw_addr)
88 {
89 return -1;
90 }
91
92 static inline struct libio_range
93 *register_libio_range(struct libio_range *newrange)
94 {
95 return NULL;
96 }
97
98 static inline resource_size_t libio_to_hwaddr(unsigned long pio)
99 {
100 return -1;
101 }
102
103 static inline unsigned long libio_translate_cpuaddr(resource_size_t hw_addr)
104 {
105 return -1;
106 }
107 #endif
108
109 #ifdef CONFIG_ACPI
110 extern int acpi_set_libio_resource(struct device *child,
111 struct device *hostdev);
112 #else
113 static inline int acpi_set_libio_resource(struct device *child,
114 struct device *hostdev)
115 {
116 return -EFAULT;
117 }
118 #endif /* CONFIG_ACPI */
119 #endif /* __KERNEL__ */
120 #endif /* __LINUX_LIBIO_H */