blob: c46f0e91d085626738d8490044274e98508a1d29 [file] [log] [blame]
Simon Glassd6ffb002017-05-17 17:18:04 -06001/*
2 * Copyright (c) 2017 Google, Inc
3 *
4 * (C) Copyright 2012
5 * Pavel Herrmann <morpheus.ibis@gmail.com>
6 * Marek Vasut <marex@denx.de>
7 *
8 * SPDX-License-Identifier: GPL-2.0+
9 */
10
Simon Glass38d21b42017-05-18 20:08:59 -060011#ifndef _DM_FDTADDR_H
12#define _DM_FDTADDR_H
Simon Glassd6ffb002017-05-17 17:18:04 -060013
14#include <fdtdec.h>
15
16struct udevice;
17
18/**
Simon Glassa821c4a2017-05-17 17:18:05 -060019 * devfdt_get_addr() - Get the reg property of a device
Simon Glassd6ffb002017-05-17 17:18:04 -060020 *
21 * @dev: Pointer to a device
22 *
23 * @return addr
24 */
Simon Glassa821c4a2017-05-17 17:18:05 -060025fdt_addr_t devfdt_get_addr(struct udevice *dev);
Simon Glassd6ffb002017-05-17 17:18:04 -060026
27/**
Simon Glassa821c4a2017-05-17 17:18:05 -060028 * devfdt_get_addr_ptr() - Return pointer to the address of the reg property
Simon Glassd6ffb002017-05-17 17:18:04 -060029 * of a device
30 *
31 * @dev: Pointer to a device
32 *
33 * @return Pointer to addr, or NULL if there is no such property
34 */
Simon Glassa821c4a2017-05-17 17:18:05 -060035void *devfdt_get_addr_ptr(struct udevice *dev);
Simon Glassd6ffb002017-05-17 17:18:04 -060036
37/**
Simon Glassa821c4a2017-05-17 17:18:05 -060038 * devfdt_map_physmem() - Read device address from reg property of the
Simon Glassd6ffb002017-05-17 17:18:04 -060039 * device node and map the address into CPU address
40 * space.
41 *
42 * @dev: Pointer to device
43 * @size: size of the memory to map
44 *
45 * @return mapped address, or NULL if the device does not have reg
46 * property.
47 */
Simon Glassa821c4a2017-05-17 17:18:05 -060048void *devfdt_map_physmem(struct udevice *dev, unsigned long size);
Simon Glassd6ffb002017-05-17 17:18:04 -060049
50/**
Simon Glassa821c4a2017-05-17 17:18:05 -060051 * devfdt_get_addr_index() - Get the indexed reg property of a device
Simon Glassd6ffb002017-05-17 17:18:04 -060052 *
53 * @dev: Pointer to a device
54 * @index: the 'reg' property can hold a list of <addr, size> pairs
55 * and @index is used to select which one is required
56 *
57 * @return addr
58 */
Simon Glassa821c4a2017-05-17 17:18:05 -060059fdt_addr_t devfdt_get_addr_index(struct udevice *dev, int index);
Simon Glassd6ffb002017-05-17 17:18:04 -060060
61/**
Simon Glassa821c4a2017-05-17 17:18:05 -060062 * devfdt_get_addr_size_index() - Get the indexed reg property of a device
Simon Glassd6ffb002017-05-17 17:18:04 -060063 *
64 * Returns the address and size specified in the 'reg' property of a device.
65 *
66 * @dev: Pointer to a device
67 * @index: the 'reg' property can hold a list of <addr, size> pairs
68 * and @index is used to select which one is required
69 * @size: Pointer to size varible - this function returns the size
70 * specified in the 'reg' property here
71 *
72 * @return addr
73 */
Simon Glassa821c4a2017-05-17 17:18:05 -060074fdt_addr_t devfdt_get_addr_size_index(struct udevice *dev, int index,
Simon Glassd6ffb002017-05-17 17:18:04 -060075 fdt_size_t *size);
76
77/**
Simon Glassa821c4a2017-05-17 17:18:05 -060078 * devfdt_get_addr_name() - Get the reg property of a device, indexed by name
Simon Glassd6ffb002017-05-17 17:18:04 -060079 *
80 * @dev: Pointer to a device
81 * @name: the 'reg' property can hold a list of <addr, size> pairs, with the
82 * 'reg-names' property providing named-based identification. @index
83 * indicates the value to search for in 'reg-names'.
84 *
85 * @return addr
86 */
Simon Glassa821c4a2017-05-17 17:18:05 -060087fdt_addr_t devfdt_get_addr_name(struct udevice *dev, const char *name);
Simon Glassd6ffb002017-05-17 17:18:04 -060088
89/**
90 * dm_set_translation_offset() - Set translation offset
91 * @offs: Translation offset
92 *
93 * Some platforms need a special address translation. Those
94 * platforms (e.g. mvebu in SPL) can configure a translation
95 * offset in the DM by calling this function. It will be
Simon Glassa821c4a2017-05-17 17:18:05 -060096 * added to all addresses returned in devfdt_get_addr().
Simon Glassd6ffb002017-05-17 17:18:04 -060097 */
98void dm_set_translation_offset(fdt_addr_t offs);
99
100/**
101 * dm_get_translation_offset() - Get translation offset
102 *
103 * This function returns the translation offset that can
104 * be configured by calling dm_set_translation_offset().
105 *
106 * @return translation offset for the device address (0 as default).
107 */
108fdt_addr_t dm_get_translation_offset(void);
109
110#endif