]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - include/linux/libio.h
UBUNTU: SAUCE: LIBIO: Introduce a generic PIO mapping method
[mirror_ubuntu-artful-kernel.git] / include / linux / libio.h
CommitLineData
90a4bbef 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/fwnode.h>
24
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
29
30struct libio_range {
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;
36 unsigned long flags;
37 void *devpara; /* private parameter of the host device */
38 struct libio_ops *ops; /* ops operating on this node */
39};
40
41struct libio_ops {
42 u32 (*pfin)(void *devobj, unsigned long ptaddr, size_t dlen);
43 void (*pfout)(void *devobj, unsigned long ptaddr, u32 outval,
44 size_t dlen);
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);
49};
50
51extern u8 libio_inb(unsigned long addr);
52extern void libio_outb(u8 value, unsigned long addr);
53extern void libio_outw(u16 value, unsigned long addr);
54extern void libio_outl(u32 value, unsigned long addr);
55extern u16 libio_inw(unsigned long addr);
56extern u32 libio_inl(unsigned long addr);
57extern void libio_outb(u8 value, unsigned long addr);
58extern void libio_outw(u16 value, unsigned long addr);
59extern void libio_outl(u32 value, unsigned long addr);
60extern void libio_insb(unsigned long addr, void *buffer, unsigned int count);
61extern void libio_insl(unsigned long addr, void *buffer, unsigned int count);
62extern void libio_insw(unsigned long addr, void *buffer, unsigned int count);
63extern void libio_outsb(unsigned long addr, const void *buffer,
64 unsigned int count);
65extern void libio_outsw(unsigned long addr, const void *buffer,
66 unsigned int count);
67extern void libio_outsl(unsigned long addr, const void *buffer,
68 unsigned int count);
69#ifdef CONFIG_LIBIO
70extern struct libio_range
71*find_io_range_from_fwnode(struct fwnode_handle *fwnode);
72extern unsigned long libio_translate_hwaddr(struct fwnode_handle *fwnode,
73 resource_size_t hw_addr);
74#else
75static inline struct libio_range
76*find_io_range_from_fwnode(struct fwnode_handle *fwnode)
77{
78 return NULL;
79}
80
81static inline unsigned long libio_translate_hwaddr(struct fwnode_handle *fwnode,
82 resource_size_t hw_addr)
83{
84 return -1;
85}
86#endif
87
88extern struct libio_range *register_libio_range(struct libio_range *newrange);
89extern resource_size_t libio_to_hwaddr(unsigned long pio);
90
91extern unsigned long libio_translate_cpuaddr(resource_size_t hw_addr);
92
93#endif /* __KERNEL__ */
94#endif /* __LINUX_LIBIO_H */