summaryrefslogtreecommitdiff
path: root/include/dm/fdtaddr.h
blob: 959d3bc2d69934937b217932867c53ffc60fcbaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * Copyright (c) 2017 Google, Inc
 *
 * (C) Copyright 2012
 * Pavel Herrmann <morpheus.ibis@gmail.com>
 * Marek Vasut <marex@denx.de>
 */

#ifndef _DM_FDTADDR_H
#define _DM_FDTADDR_H

#include <fdtdec.h>

struct udevice;

/**
 * devfdt_get_addr() - Get the reg property of a device
 *
 * @dev: Pointer to a device
 *
 * @return addr
 */
fdt_addr_t devfdt_get_addr(struct udevice *dev);

/**
 * devfdt_get_addr_ptr() - Return pointer to the address of the reg property
 *                      of a device
 *
 * @dev: Pointer to a device
 *
 * @return Pointer to addr, or NULL if there is no such property
 */
void *devfdt_get_addr_ptr(struct udevice *dev);

/**
 * devfdt_remap_addr() - Return pointer to the memory-mapped I/O address
 *                           of the reg property of a device
 *
 * @dev: Pointer to a device
 *
 * @return Pointer to addr, or NULL if there is no such property
 */
void *devfdt_remap_addr(struct udevice *dev);

/**
 * devfdt_remap_addr_index() - Return indexed pointer to the memory-mapped
 *                                 I/O address of the reg property of a device
 * @index: the 'reg' property can hold a list of <addr, size> pairs
 *	   and @index is used to select which one is required
 *
 * @dev: Pointer to a device
 *
 * @return Pointer to addr, or NULL if there is no such property
 */
void *devfdt_remap_addr_index(struct udevice *dev, int index);

/**
 * devfdt_remap_addr_name() - Get the reg property of a device, indexed by
 *                            name, as a memory-mapped I/O pointer
 * @name: the 'reg' property can hold a list of <addr, size> pairs, with the
 *	  'reg-names' property providing named-based identification. @index
 *	  indicates the value to search for in 'reg-names'.
 *
 * @dev: Pointer to a device
 *
 * @return Pointer to addr, or NULL if there is no such property
 */
void *devfdt_remap_addr_name(struct udevice *dev, const char *name);

/**
 * devfdt_map_physmem() - Read device address from reg property of the
 *                     device node and map the address into CPU address
 *                     space.
 *
 * @dev: Pointer to device
 * @size: size of the memory to map
 *
 * @return  mapped address, or NULL if the device does not have reg
 *          property.
 */
void *devfdt_map_physmem(struct udevice *dev, unsigned long size);

/**
 * devfdt_get_addr_index() - Get the indexed reg property of a device
 *
 * @dev: Pointer to a device
 * @index: the 'reg' property can hold a list of <addr, size> pairs
 *	   and @index is used to select which one is required
 *
 * @return addr
 */
fdt_addr_t devfdt_get_addr_index(struct udevice *dev, int index);

/**
 * devfdt_get_addr_size_index() - Get the indexed reg property of a device
 *
 * Returns the address and size specified in the 'reg' property of a device.
 *
 * @dev: Pointer to a device
 * @index: the 'reg' property can hold a list of <addr, size> pairs
 *	   and @index is used to select which one is required
 * @size: Pointer to size varible - this function returns the size
 *        specified in the 'reg' property here
 *
 * @return addr
 */
fdt_addr_t devfdt_get_addr_size_index(struct udevice *dev, int index,
				   fdt_size_t *size);

/**
 * devfdt_get_addr_name() - Get the reg property of a device, indexed by name
 *
 * @dev: Pointer to a device
 * @name: the 'reg' property can hold a list of <addr, size> pairs, with the
 *	  'reg-names' property providing named-based identification. @index
 *	  indicates the value to search for in 'reg-names'.
 *
 * @return addr
 */
fdt_addr_t devfdt_get_addr_name(struct udevice *dev, const char *name);

/**
 * devfdt_get_addr_size_name() - Get the reg property and its size for a device,
 *				 indexed by name
 *
 * Returns the address and size specified in the 'reg' property of a device.
 *
 * @dev: Pointer to a device
 * @name: the 'reg' property can hold a list of <addr, size> pairs, with the
 *	  'reg-names' property providing named-based identification. @index
 *	  indicates the value to search for in 'reg-names'.
 * @size: Pointer to size variable - this function returns the size
 *        specified in the 'reg' property here
 *
 * @return addr
 */
fdt_addr_t devfdt_get_addr_size_name(struct udevice *dev, const char *name,
				     fdt_size_t *size);

/**
 * devfdt_get_addr_pci() - Read an address and handle PCI address translation
 *
 * @dev: Device to read from
 * @return address or FDT_ADDR_T_NONE if not found
 */
fdt_addr_t devfdt_get_addr_pci(struct udevice *dev);

#endif