Add Broadcom's code for bcm63xx support
[project/bcm63xx/atf.git] / plat / bcm / drivers / io.h
1 /*
2 <:copyright-BRCM:2019:DUAL/GPL:standard
3
4 Copyright (c) 2019 Broadcom
5 All Rights Reserved
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License, version 2, as published by
9 the Free Software Foundation (the "GPL").
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16
17 A copy of the GPL is available at http://www.broadcom.com/licenses/GPLv2.php, or by
18 writing to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
20
21 :>
22 */
23 /*
24 * io.h for atf
25 * Created by <nschichan@freebox.fr> on Thu Apr 18 19:26:20 2019
26 */
27
28 #pragma once
29
30 #include <mmio.h>
31
32 typedef uint64_t u64;
33 typedef uint32_t u32;
34 typedef uint16_t u16;
35 typedef uint8_t u8;
36
37 typedef int64_t s64;
38 typedef int32_t s32;
39 typedef int16_t s16;
40 typedef int8_t s8;
41
42 static inline u64 readq(void *mem)
43 {
44 return mmio_read_64((uintptr_t)mem);
45 }
46
47 static inline u32 readl(void *mem)
48 {
49 return mmio_read_32((uintptr_t)mem);
50 }
51
52 static inline u16 readw(void *mem)
53 {
54 return mmio_read_16((uintptr_t)mem);
55 }
56
57 static inline u8 readb(void *mem)
58 {
59 return mmio_read_8((uintptr_t)mem);
60 }
61
62 static inline void writeq(u64 v, void *mem)
63 {
64 return mmio_write_64((uintptr_t)mem, v);
65 }
66
67 static inline void writel(u32 v, void *mem)
68 {
69 return mmio_write_32((uintptr_t)mem, v);
70 }
71
72 static inline void writew(u16 v, void *mem)
73 {
74 return mmio_write_16((uintptr_t)mem, v);
75 }
76
77 static inline void writeb(u8 v, void *mem)
78 {
79 return mmio_write_8((uintptr_t)mem, v);
80 }