linux/include/linux/logic_pio.h

// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright (C) 2017 HiSilicon Limited, All Rights Reserved.
 * Author: Gabriele Paoloni <[email protected]>
 * Author: Zhichang Yuan <[email protected]>
 */

#ifndef __LINUX_LOGIC_PIO_H
#define __LINUX_LOGIC_PIO_H

#include <linux/fwnode.h>

enum {};

struct logic_pio_hwaddr {};

struct logic_pio_host_ops {};

#ifdef CONFIG_INDIRECT_PIO
u8 logic_inb(unsigned long addr);
u16 logic_inw(unsigned long addr);
u32 logic_inl(unsigned long addr);
void logic_outb(u8 value, unsigned long addr);
void logic_outw(u16 value, unsigned long addr);
void logic_outl(u32 value, unsigned long addr);
void logic_insb(unsigned long addr, void *buffer, unsigned int count);
void logic_insl(unsigned long addr, void *buffer, unsigned int count);
void logic_insw(unsigned long addr, void *buffer, unsigned int count);
void logic_outsb(unsigned long addr, const void *buffer, unsigned int count);
void logic_outsw(unsigned long addr, const void *buffer, unsigned int count);
void logic_outsl(unsigned long addr, const void *buffer, unsigned int count);

#ifndef inb
#define inb
#endif

#ifndef inw
#define inw
#endif

#ifndef inl
#define inl
#endif

#ifndef outb
#define outb
#endif

#ifndef outw
#define outw
#endif

#ifndef outl
#define outl
#endif

#ifndef insb
#define insb
#endif

#ifndef insw
#define insw
#endif

#ifndef insl
#define insl
#endif

#ifndef outsb
#define outsb
#endif

#ifndef outsw
#define outsw
#endif

#ifndef outsl
#define outsl
#endif

/*
 * We reserve 0x4000 bytes for Indirect IO as so far this library is only
 * used by the HiSilicon LPC Host. If needed, we can reserve a wider IO
 * area by redefining the macro below.
 */
#define PIO_INDIRECT_SIZE
#else
#define PIO_INDIRECT_SIZE
#endif /* CONFIG_INDIRECT_PIO */
#define MMIO_UPPER_LIMIT

struct logic_pio_hwaddr *find_io_range_by_fwnode(struct fwnode_handle *fwnode);
unsigned long logic_pio_trans_hwaddr(struct fwnode_handle *fwnode,
			resource_size_t hw_addr, resource_size_t size);
int logic_pio_register_range(struct logic_pio_hwaddr *newrange);
void logic_pio_unregister_range(struct logic_pio_hwaddr *range);
resource_size_t logic_pio_to_hwaddr(unsigned long pio);
unsigned long logic_pio_trans_cpuaddr(resource_size_t hw_addr);

#endif /* __LINUX_LOGIC_PIO_H */