]>
git.ipfire.org Git - people/ms/u-boot.git/blob - board/MAI/AmigaOneG3SE/memio.h
5 * Hyperion Entertainment, ThomasF@hyperion-entertainment.com
7 * See file CREDITS for list of people who contributed to this
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 * You may also use this under a BSD license.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
25 #include "short_types.h"
27 #define IOBASE 0xFE000000
29 #define in_byte(from) read_byte( (uint8 *)(IOBASE | (from)))
30 #define in_word(from) read_word_little((uint16 *)(IOBASE | (from)))
31 #define in_long(from) read_long_little((uint32 *)(IOBASE | (from)))
32 #define out_byte(to, val) write_byte((uint8 *)(IOBASE | (to)), val)
33 #define out_word(to, val) write_word_little((uint16 *)(IOBASE | (to)), val)
34 #define out_long(to, val) write_long_little((uint32 *)(IOBASE | (to)), val)
37 static inline uint8
read_byte(volatile uint8
*from
)
40 asm volatile ("lbz %0,%1\n eieio\n sync" : "=r" (x
) : "m" (*from
));
45 static inline void write_byte(volatile uint8
*to
, uint8 x
)
47 asm volatile ("stb %1,%0\n eieio\n sync" : "=m" (*to
) : "r" (x
));
50 static inline uint16
read_word_little(volatile uint16
*from
)
53 asm volatile ("lhbrx %0,0,%1\n eieio\n sync" : "=r" (x
) : "r" (from
), "m" (*from
));
57 static inline uint16
read_word_big(volatile uint16
*from
)
60 asm volatile ("lhz %0,%1\n eieio\n sync" : "=r" (x
) : "m" (*from
));
64 static inline void write_word_little(volatile uint16
*to
, int x
)
66 asm volatile ("sthbrx %1,0,%2\n eieio\n sync" : "=m" (*to
) : "r" (x
), "r" (to
));
69 static inline void write_word_big(volatile uint16
*to
, int x
)
71 asm volatile ("sth %1,%0\n eieio\n sync" : "=m" (*to
) : "r" (x
));
74 static inline uint32
read_long_little(volatile uint32
*from
)
77 asm volatile ("lwbrx %0,0,%1\n eieio\n sync" : "=r" (x
) : "r" (from
), "m"(*from
));
81 static inline uint32
read_long_big(volatile uint32
*from
)
84 asm volatile ("lwz %0,%1\n eieio\n sync" : "=r" (x
) : "m" (*from
));
88 static inline void write_long_little(volatile uint32
*to
, uint32 x
)
90 asm volatile ("stwbrx %1,0,%2\n eieio\n sync" : "=m" (*to
) : "r" (x
), "r" (to
));
93 static inline void write_long_big(volatile uint32
*to
, uint32 x
)
95 asm volatile ("stw %1,%0\n eieio\n sync" : "=m" (*to
) : "r" (x
));
98 #define CONFIG_ADDR(bus, devfn, offset) \
99 write_long_big((uint32 *)0xFEC00CF8, \
100 ((offset & 0xFC)<<24) | (devfn << 16) \
102 #define CONFIG_DATA(offset,mask) ((void *)(0xFEE00CFC+(offset & mask)))
105 uint8
pci_read_cfg_byte(int32 bus
, int32 devfn
, int32 offset
);
106 void pci_write_cfg_byte(int32 bus
, int32 devfn
, int32 offset
, uint8 x
);
107 uint16
pci_read_cfg_word(int32 bus
, int32 devfn
, int32 offset
);
108 void pci_write_cfg_word(int32 bus
, int32 devfn
, int32 offset
, uint16 x
);
109 uint32
pci_read_cfg_long(int32 bus
, int32 devfn
, int32 offset
);
110 void pci_write_cfg_long(int32 bus
, int32 devfn
, int32 offset
, uint32 x
);