blob: 49a6ffd5f8325162decedb75435e3682033feb4b [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glassaadfaf02017-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 Glassaadfaf02017-05-17 17:18:04 -06008 */
9
Simon Glass6fe43a32017-05-18 20:08:59 -060010#ifndef _DM_FDTADDR_H
11#define _DM_FDTADDR_H
Simon Glassaadfaf02017-05-17 17:18:04 -060012
13#include <fdtdec.h>
14
15struct udevice;
16
17/**
Simon Glassba1dea42017-05-17 17:18:05 -060018 * devfdt_get_addr() - Get the reg property of a device
Simon Glassaadfaf02017-05-17 17:18:04 -060019 *
20 * @dev: Pointer to a device
21 *
22 * @return addr
23 */
Simon Glassba1dea42017-05-17 17:18:05 -060024fdt_addr_t devfdt_get_addr(struct udevice *dev);
Simon Glassaadfaf02017-05-17 17:18:04 -060025
26/**
Simon Glassba1dea42017-05-17 17:18:05 -060027 * devfdt_get_addr_ptr() - Return pointer to the address of the reg property
Simon Glassaadfaf02017-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 Glassba1dea42017-05-17 17:18:05 -060034void *devfdt_get_addr_ptr(struct udevice *dev);
Simon Glassaadfaf02017-05-17 17:18:04 -060035
36/**
Álvaro Fernández Rojas670361292018-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/**
Simon Glassba1dea42017-05-17 17:18:05 -060059 * devfdt_map_physmem() - Read device address from reg property of the
Simon Glassaadfaf02017-05-17 17:18:04 -060060 * device node and map the address into CPU address
61 * space.
62 *
63 * @dev: Pointer to device
64 * @size: size of the memory to map
65 *
66 * @return mapped address, or NULL if the device does not have reg
67 * property.
68 */
Simon Glassba1dea42017-05-17 17:18:05 -060069void *devfdt_map_physmem(struct udevice *dev, unsigned long size);
Simon Glassaadfaf02017-05-17 17:18:04 -060070
71/**
Simon Glassba1dea42017-05-17 17:18:05 -060072 * devfdt_get_addr_index() - Get the indexed reg property of a device
Simon Glassaadfaf02017-05-17 17:18:04 -060073 *
74 * @dev: Pointer to a device
75 * @index: the 'reg' property can hold a list of <addr, size> pairs
76 * and @index is used to select which one is required
77 *
78 * @return addr
79 */
Simon Glassba1dea42017-05-17 17:18:05 -060080fdt_addr_t devfdt_get_addr_index(struct udevice *dev, int index);
Simon Glassaadfaf02017-05-17 17:18:04 -060081
82/**
Simon Glassba1dea42017-05-17 17:18:05 -060083 * devfdt_get_addr_size_index() - Get the indexed reg property of a device
Simon Glassaadfaf02017-05-17 17:18:04 -060084 *
85 * Returns the address and size specified in the 'reg' property of a device.
86 *
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 * @size: Pointer to size varible - this function returns the size
91 * specified in the 'reg' property here
92 *
93 * @return addr
94 */
Simon Glassba1dea42017-05-17 17:18:05 -060095fdt_addr_t devfdt_get_addr_size_index(struct udevice *dev, int index,
Simon Glassaadfaf02017-05-17 17:18:04 -060096 fdt_size_t *size);
97
98/**
Simon Glassba1dea42017-05-17 17:18:05 -060099 * devfdt_get_addr_name() - Get the reg property of a device, indexed by name
Simon Glassaadfaf02017-05-17 17:18:04 -0600100 *
101 * @dev: Pointer to a device
102 * @name: the 'reg' property can hold a list of <addr, size> pairs, with the
103 * 'reg-names' property providing named-based identification. @index
104 * indicates the value to search for in 'reg-names'.
105 *
106 * @return addr
107 */
Simon Glassba1dea42017-05-17 17:18:05 -0600108fdt_addr_t devfdt_get_addr_name(struct udevice *dev, const char *name);
Simon Glassaadfaf02017-05-17 17:18:04 -0600109
110/**
111 * dm_set_translation_offset() - Set translation offset
112 * @offs: Translation offset
113 *
114 * Some platforms need a special address translation. Those
115 * platforms (e.g. mvebu in SPL) can configure a translation
116 * offset in the DM by calling this function. It will be
Simon Glassba1dea42017-05-17 17:18:05 -0600117 * added to all addresses returned in devfdt_get_addr().
Simon Glassaadfaf02017-05-17 17:18:04 -0600118 */
119void dm_set_translation_offset(fdt_addr_t offs);
120
121/**
122 * dm_get_translation_offset() - Get translation offset
123 *
124 * This function returns the translation offset that can
125 * be configured by calling dm_set_translation_offset().
126 *
127 * @return translation offset for the device address (0 as default).
128 */
129fdt_addr_t dm_get_translation_offset(void);
130
131#endif