blob: c171d9bc2f42898aa02795280102f3e654132243 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glassd6ffb002017-05-17 17:18:04 -06002/*
3 * Copyright (c) 2017 Google, Inc
4 *
5 * (C) Copyright 2012
6 * Pavel Herrmann <morpheus.ibis@gmail.com>
7 * Marek Vasut <marex@denx.de>
Simon Glassd6ffb002017-05-17 17:18:04 -06008 */
9
Simon Glass38d21b42017-05-18 20:08:59 -060010#ifndef _DM_FDTADDR_H
11#define _DM_FDTADDR_H
Simon Glassd6ffb002017-05-17 17:18:04 -060012
13#include <fdtdec.h>
14
15struct udevice;
16
17/**
Simon Glassa821c4a2017-05-17 17:18:05 -060018 * devfdt_get_addr() - Get the reg property of a device
Simon Glassd6ffb002017-05-17 17:18:04 -060019 *
20 * @dev: Pointer to a device
21 *
22 * @return addr
23 */
Simon Glassa821c4a2017-05-17 17:18:05 -060024fdt_addr_t devfdt_get_addr(struct udevice *dev);
Simon Glassd6ffb002017-05-17 17:18:04 -060025
26/**
Simon Glassa821c4a2017-05-17 17:18:05 -060027 * devfdt_get_addr_ptr() - Return pointer to the address of the reg property
Simon Glassd6ffb002017-05-17 17:18:04 -060028 * of a device
29 *
30 * @dev: Pointer to a device
31 *
32 * @return Pointer to addr, or NULL if there is no such property
33 */
Simon Glassa821c4a2017-05-17 17:18:05 -060034void *devfdt_get_addr_ptr(struct udevice *dev);
Simon Glassd6ffb002017-05-17 17:18:04 -060035
36/**
Álvaro Fernández Rojas30a90f52018-04-29 21:56:54 +020037 * devfdt_remap_addr() - Return pointer to the memory-mapped I/O address
38 * of the reg property of a device
39 *
40 * @dev: Pointer to a device
41 *
42 * @return Pointer to addr, or NULL if there is no such property
43 */
44void *devfdt_remap_addr(struct udevice *dev);
45
46/**
47 * devfdt_remap_addr_index() - Return indexed pointer to the memory-mapped
48 * I/O address of the reg property of a device
49 * @index: the 'reg' property can hold a list of <addr, size> pairs
50 * and @index is used to select which one is required
51 *
52 * @dev: Pointer to a device
53 *
54 * @return Pointer to addr, or NULL if there is no such property
55 */
56void *devfdt_remap_addr_index(struct udevice *dev, int index);
57
58/**
Álvaro Fernández Rojas79598822018-12-03 19:37:09 +010059 * devfdt_remap_addr_name() - Get the reg property of a device, indexed by
60 * name, as a memory-mapped I/O pointer
61 * @name: the 'reg' property can hold a list of <addr, size> pairs, with the
62 * 'reg-names' property providing named-based identification. @index
63 * indicates the value to search for in 'reg-names'.
64 *
65 * @dev: Pointer to a device
66 *
67 * @return Pointer to addr, or NULL if there is no such property
68 */
69void *devfdt_remap_addr_name(struct udevice *dev, const char *name);
70
71/**
Simon Glassa821c4a2017-05-17 17:18:05 -060072 * devfdt_map_physmem() - Read device address from reg property of the
Simon Glassd6ffb002017-05-17 17:18:04 -060073 * device node and map the address into CPU address
74 * space.
75 *
76 * @dev: Pointer to device
77 * @size: size of the memory to map
78 *
79 * @return mapped address, or NULL if the device does not have reg
80 * property.
81 */
Simon Glassa821c4a2017-05-17 17:18:05 -060082void *devfdt_map_physmem(struct udevice *dev, unsigned long size);
Simon Glassd6ffb002017-05-17 17:18:04 -060083
84/**
Simon Glassa821c4a2017-05-17 17:18:05 -060085 * devfdt_get_addr_index() - Get the indexed reg property of a device
Simon Glassd6ffb002017-05-17 17:18:04 -060086 *
87 * @dev: Pointer to a device
88 * @index: the 'reg' property can hold a list of <addr, size> pairs
89 * and @index is used to select which one is required
90 *
91 * @return addr
92 */
Simon Glassa821c4a2017-05-17 17:18:05 -060093fdt_addr_t devfdt_get_addr_index(struct udevice *dev, int index);
Simon Glassd6ffb002017-05-17 17:18:04 -060094
95/**
Simon Glassa821c4a2017-05-17 17:18:05 -060096 * devfdt_get_addr_size_index() - Get the indexed reg property of a device
Simon Glassd6ffb002017-05-17 17:18:04 -060097 *
98 * Returns the address and size specified in the 'reg' property of a device.
99 *
100 * @dev: Pointer to a device
101 * @index: the 'reg' property can hold a list of <addr, size> pairs
102 * and @index is used to select which one is required
103 * @size: Pointer to size varible - this function returns the size
104 * specified in the 'reg' property here
105 *
106 * @return addr
107 */
Simon Glassa821c4a2017-05-17 17:18:05 -0600108fdt_addr_t devfdt_get_addr_size_index(struct udevice *dev, int index,
Simon Glassd6ffb002017-05-17 17:18:04 -0600109 fdt_size_t *size);
110
111/**
Simon Glassa821c4a2017-05-17 17:18:05 -0600112 * devfdt_get_addr_name() - Get the reg property of a device, indexed by name
Simon Glassd6ffb002017-05-17 17:18:04 -0600113 *
114 * @dev: Pointer to a device
115 * @name: the 'reg' property can hold a list of <addr, size> pairs, with the
116 * 'reg-names' property providing named-based identification. @index
117 * indicates the value to search for in 'reg-names'.
118 *
119 * @return addr
120 */
Simon Glassa821c4a2017-05-17 17:18:05 -0600121fdt_addr_t devfdt_get_addr_name(struct udevice *dev, const char *name);
Simon Glassd6ffb002017-05-17 17:18:04 -0600122
123/**
124 * dm_set_translation_offset() - Set translation offset
125 * @offs: Translation offset
126 *
127 * Some platforms need a special address translation. Those
128 * platforms (e.g. mvebu in SPL) can configure a translation
129 * offset in the DM by calling this function. It will be
Simon Glassa821c4a2017-05-17 17:18:05 -0600130 * added to all addresses returned in devfdt_get_addr().
Simon Glassd6ffb002017-05-17 17:18:04 -0600131 */
132void dm_set_translation_offset(fdt_addr_t offs);
133
134/**
135 * dm_get_translation_offset() - Get translation offset
136 *
137 * This function returns the translation offset that can
138 * be configured by calling dm_set_translation_offset().
139 *
140 * @return translation offset for the device address (0 as default).
141 */
142fdt_addr_t dm_get_translation_offset(void);
143
144#endif