]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - include/linux/libio.h
2 * Copyright (C) 2017 Hisilicon Limited, All Rights Reserved.
3 * Author: Zhichang Yuan <yuanzhichang@hisilicon.com>
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.
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.
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/>.
18 #ifndef __LINUX_LIBIO_H
19 #define __LINUX_LIBIO_H
23 #include <linux/device.h>
24 #include <linux/fwnode.h>
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
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
;
38 void *devpara
; /* private parameter of the host device */
39 struct libio_ops
*ops
; /* ops operating on this node */
43 u32 (*pfin
)(void *devobj
, unsigned long ptaddr
, size_t dlen
);
44 void (*pfout
)(void *devobj
, unsigned long ptaddr
, u32 outval
,
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
);
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
,
66 extern void libio_outsw(unsigned long addr
, const void *buffer
,
68 extern void libio_outsl(unsigned long addr
, const void *buffer
,
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
);
78 extern unsigned long libio_translate_cpuaddr(resource_size_t hw_addr
);
80 static inline struct libio_range
81 *find_io_range_from_fwnode(struct fwnode_handle
*fwnode
)
86 static inline unsigned long libio_translate_hwaddr(struct fwnode_handle
*fwnode
,
87 resource_size_t hw_addr
)
92 static inline struct libio_range
93 *register_libio_range(struct libio_range
*newrange
)
98 static inline resource_size_t
libio_to_hwaddr(unsigned long pio
)
103 static inline unsigned long libio_translate_cpuaddr(resource_size_t hw_addr
)
110 extern int acpi_set_libio_resource(struct device
*child
,
111 struct device
*hostdev
);
113 static inline int acpi_set_libio_resource(struct device
*child
,
114 struct device
*hostdev
)
118 #endif /* CONFIG_ACPI */
119 #endif /* __KERNEL__ */
120 #endif /* __LINUX_LIBIO_H */