]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - include/linux/libio.h
91038aa37b8a5e44426c9805b276fafb9a0bae0b
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/fwnode.h>
25 /* This is compatible to PCI MMIO. */
26 #define IO_CPU_MMIO 0x01
27 /* All hosts where there are no CPU addr */
28 #define IO_HOST_INDIRECT 0x02
31 struct list_head list
;
32 struct fwnode_handle
*node
;
33 resource_size_t size
; /* range size populated */
34 resource_size_t io_start
; /* logical pio start. inclusive */
35 resource_size_t hw_start
;
37 void *devpara
; /* private parameter of the host device */
38 struct libio_ops
*ops
; /* ops operating on this node */
42 u32 (*pfin
)(void *devobj
, unsigned long ptaddr
, size_t dlen
);
43 void (*pfout
)(void *devobj
, unsigned long ptaddr
, u32 outval
,
45 u32 (*pfins
)(void *devobj
, unsigned long ptaddr
, void *inbuf
,
46 size_t dlen
, unsigned int count
);
47 void (*pfouts
)(void *devobj
, unsigned long ptaddr
,
48 const void *outbuf
, size_t dlen
, unsigned int count
);
51 extern u8
libio_inb(unsigned long addr
);
52 extern void libio_outb(u8 value
, unsigned long addr
);
53 extern void libio_outw(u16 value
, unsigned long addr
);
54 extern void libio_outl(u32 value
, unsigned long addr
);
55 extern u16
libio_inw(unsigned long addr
);
56 extern u32
libio_inl(unsigned long addr
);
57 extern void libio_outb(u8 value
, unsigned long addr
);
58 extern void libio_outw(u16 value
, unsigned long addr
);
59 extern void libio_outl(u32 value
, unsigned long addr
);
60 extern void libio_insb(unsigned long addr
, void *buffer
, unsigned int count
);
61 extern void libio_insl(unsigned long addr
, void *buffer
, unsigned int count
);
62 extern void libio_insw(unsigned long addr
, void *buffer
, unsigned int count
);
63 extern void libio_outsb(unsigned long addr
, const void *buffer
,
65 extern void libio_outsw(unsigned long addr
, const void *buffer
,
67 extern void libio_outsl(unsigned long addr
, const void *buffer
,
70 extern struct libio_range
71 *find_io_range_from_fwnode(struct fwnode_handle
*fwnode
);
72 extern unsigned long libio_translate_hwaddr(struct fwnode_handle
*fwnode
,
73 resource_size_t hw_addr
);
75 static inline struct libio_range
76 *find_io_range_from_fwnode(struct fwnode_handle
*fwnode
)
81 static inline unsigned long libio_translate_hwaddr(struct fwnode_handle
*fwnode
,
82 resource_size_t hw_addr
)
88 extern struct libio_range
*register_libio_range(struct libio_range
*newrange
);
89 extern resource_size_t
libio_to_hwaddr(unsigned long pio
);
91 extern unsigned long libio_translate_cpuaddr(resource_size_t hw_addr
);
93 #endif /* __KERNEL__ */
94 #endif /* __LINUX_LIBIO_H */