blob: fd3c2478f7f1e77dae8aae422930f60f6572dc62 [file] [log] [blame]
Simon Glass744d9852011-10-10 08:22:14 +00001/*
2 * Copyright (c) 2011 The Chromium OS Authors.
3 *
Wolfgang Denk3765b3e2013-10-07 13:07:26 +02004 * SPDX-License-Identifier: GPL-2.0+
Simon Glass744d9852011-10-10 08:22:14 +00005 */
6
Simon Glassa733b062013-04-26 02:53:43 +00007#ifndef __SANDBOX_ASM_IO_H
8#define __SANDBOX_ASM_IO_H
9
Paul Burtonf7ae1ca2017-09-14 15:05:13 -070010void *phys_to_virt(phys_addr_t paddr);
11#define phys_to_virt phys_to_virt
12
13phys_addr_t virt_to_phys(void *vaddr);
14#define virt_to_phys virt_to_phys
Simon Glass744d9852011-10-10 08:22:14 +000015
16void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags);
Paul Burtonf7ae1ca2017-09-14 15:05:13 -070017#define map_physmem map_physmem
Simon Glass744d9852011-10-10 08:22:14 +000018
19/*
20 * Take down a mapping set up by map_physmem().
21 */
Simon Glass9569c402015-03-05 12:25:26 -070022void unmap_physmem(const void *vaddr, unsigned long flags);
Paul Burtonf7ae1ca2017-09-14 15:05:13 -070023#define unmap_physmem unmap_physmem
24
25#include <asm-generic/io.h>
Simon Glass4213fc22013-02-24 17:33:14 +000026
27/* For sandbox, we want addresses to point into our RAM buffer */
28static inline void *map_sysmem(phys_addr_t paddr, unsigned long len)
29{
30 return map_physmem(paddr, len, MAP_WRBACK);
31}
32
Simon Glass9569c402015-03-05 12:25:26 -070033/* Remove a previous mapping */
Simon Glass4213fc22013-02-24 17:33:14 +000034static inline void unmap_sysmem(const void *vaddr)
35{
Simon Glass9569c402015-03-05 12:25:26 -070036 unmap_physmem(vaddr, MAP_WRBACK);
Simon Glass4213fc22013-02-24 17:33:14 +000037}
Simon Glass781adb52013-04-20 08:42:37 +000038
39/* Map from a pointer to our RAM buffer */
Simon Glassed072b92013-11-07 09:31:58 -070040phys_addr_t map_to_sysmem(const void *ptr);
Simon Glassa733b062013-04-26 02:53:43 +000041
Simon Glass42d3b292014-06-11 23:29:43 -060042/* Define nops for sandbox I/O access */
Simon Glass80793db2016-10-01 14:42:33 -060043#define readb(addr) ((void)addr, 0)
44#define readw(addr) ((void)addr, 0)
45#define readl(addr) ((void)addr, 0)
46#define writeb(v, addr) ((void)addr)
47#define writew(v, addr) ((void)addr)
48#define writel(v, addr) ((void)addr)
Simon Glass42d3b292014-06-11 23:29:43 -060049
Simon Glass9569c402015-03-05 12:25:26 -070050/* I/O access functions */
51int inl(unsigned int addr);
52int inw(unsigned int addr);
53int inb(unsigned int addr);
54
55void outl(unsigned int value, unsigned int addr);
56void outw(unsigned int value, unsigned int addr);
57void outb(unsigned int value, unsigned int addr);
58
Simon Glasse54094f2016-05-01 11:35:54 -060059static inline void _insw(volatile u16 *port, void *buf, int ns)
60{
61}
62
63static inline void _outsw(volatile u16 *port, const void *buf, int ns)
64{
65}
66
67#define insw(port, buf, ns) _insw((u16 *)port, buf, ns)
68#define outsw(port, buf, ns) _outsw((u16 *)port, buf, ns)
69
70/* For systemace.c */
71#define out16(addr, val)
72#define in16(addr) 0
73
Simon Glass42d3b292014-06-11 23:29:43 -060074#include <iotrace.h>
Tom Rini690d8a92016-03-15 13:20:23 -040075#include <asm/types.h>
Simon Glass42d3b292014-06-11 23:29:43 -060076
Simon Glassa733b062013-04-26 02:53:43 +000077#endif