2018-05-06 21:58:06 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
2017-05-17 23:18:04 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2017 Google, Inc
|
|
|
|
*
|
|
|
|
* (C) Copyright 2012
|
|
|
|
* Pavel Herrmann <morpheus.ibis@gmail.com>
|
|
|
|
* Marek Vasut <marex@denx.de>
|
|
|
|
*/
|
|
|
|
|
2017-05-19 02:08:59 +00:00
|
|
|
#ifndef _DM_FDTADDR_H
|
|
|
|
#define _DM_FDTADDR_H
|
2017-05-17 23:18:04 +00:00
|
|
|
|
|
|
|
#include <fdtdec.h>
|
|
|
|
|
|
|
|
struct udevice;
|
|
|
|
|
|
|
|
/**
|
2017-05-17 23:18:05 +00:00
|
|
|
* devfdt_get_addr() - Get the reg property of a device
|
2017-05-17 23:18:04 +00:00
|
|
|
*
|
|
|
|
* @dev: Pointer to a device
|
|
|
|
*
|
2023-09-27 13:33:30 +00:00
|
|
|
* Return: Address, or FDT_ADDR_T_NONE if there is no such property
|
2017-05-17 23:18:04 +00:00
|
|
|
*/
|
2020-01-27 15:49:39 +00:00
|
|
|
fdt_addr_t devfdt_get_addr(const struct udevice *dev);
|
2017-05-17 23:18:04 +00:00
|
|
|
|
|
|
|
/**
|
2017-05-17 23:18:05 +00:00
|
|
|
* devfdt_get_addr_ptr() - Return pointer to the address of the reg property
|
2017-05-17 23:18:04 +00:00
|
|
|
* of a device
|
|
|
|
*
|
|
|
|
* @dev: Pointer to a device
|
|
|
|
*
|
2022-01-12 09:55:41 +00:00
|
|
|
* Return: Pointer to addr, or NULL if there is no such property
|
2017-05-17 23:18:04 +00:00
|
|
|
*/
|
2020-01-27 15:49:39 +00:00
|
|
|
void *devfdt_get_addr_ptr(const struct udevice *dev);
|
2017-05-17 23:18:04 +00:00
|
|
|
|
2018-04-29 19:56:54 +00:00
|
|
|
/**
|
|
|
|
* devfdt_remap_addr() - Return pointer to the memory-mapped I/O address
|
|
|
|
* of the reg property of a device
|
|
|
|
*
|
|
|
|
* @dev: Pointer to a device
|
|
|
|
*
|
2022-01-12 09:55:41 +00:00
|
|
|
* Return: Pointer to addr, or NULL if there is no such property
|
2018-04-29 19:56:54 +00:00
|
|
|
*/
|
2020-01-27 15:49:39 +00:00
|
|
|
void *devfdt_remap_addr(const struct udevice *dev);
|
2018-04-29 19:56:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*
|
2022-01-12 09:55:41 +00:00
|
|
|
* Return: Pointer to addr, or NULL if there is no such property
|
2018-04-29 19:56:54 +00:00
|
|
|
*/
|
2020-01-27 15:49:39 +00:00
|
|
|
void *devfdt_remap_addr_index(const struct udevice *dev, int index);
|
2018-04-29 19:56:54 +00:00
|
|
|
|
2018-12-03 18:37:09 +00:00
|
|
|
/**
|
|
|
|
* 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
|
2023-09-27 13:33:30 +00:00
|
|
|
* 'reg-names' property providing named-based identification. @name
|
2018-12-03 18:37:09 +00:00
|
|
|
* indicates the value to search for in 'reg-names'.
|
|
|
|
*
|
|
|
|
* @dev: Pointer to a device
|
|
|
|
*
|
2022-01-12 09:55:41 +00:00
|
|
|
* Return: Pointer to addr, or NULL if there is no such property
|
2018-12-03 18:37:09 +00:00
|
|
|
*/
|
2020-01-27 15:49:39 +00:00
|
|
|
void *devfdt_remap_addr_name(const struct udevice *dev, const char *name);
|
2018-12-03 18:37:09 +00:00
|
|
|
|
2017-05-17 23:18:04 +00:00
|
|
|
/**
|
2017-05-17 23:18:05 +00:00
|
|
|
* devfdt_map_physmem() - Read device address from reg property of the
|
2017-05-17 23:18:04 +00:00
|
|
|
* device node and map the address into CPU address
|
|
|
|
* space.
|
|
|
|
*
|
|
|
|
* @dev: Pointer to device
|
|
|
|
* @size: size of the memory to map
|
|
|
|
*
|
2022-01-12 09:55:41 +00:00
|
|
|
* Return: mapped address, or NULL if the device does not have reg property.
|
2017-05-17 23:18:04 +00:00
|
|
|
*/
|
2020-01-27 15:49:39 +00:00
|
|
|
void *devfdt_map_physmem(const struct udevice *dev, unsigned long size);
|
2017-05-17 23:18:04 +00:00
|
|
|
|
|
|
|
/**
|
2017-05-17 23:18:05 +00:00
|
|
|
* devfdt_get_addr_index() - Get the indexed reg property of a device
|
2017-05-17 23:18:04 +00:00
|
|
|
*
|
|
|
|
* @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
|
|
|
|
*
|
2023-09-27 13:33:30 +00:00
|
|
|
* Return: Address, or FDT_ADDR_T_NONE if there is no such property
|
2017-05-17 23:18:04 +00:00
|
|
|
*/
|
2020-01-27 15:49:39 +00:00
|
|
|
fdt_addr_t devfdt_get_addr_index(const struct udevice *dev, int index);
|
2017-05-17 23:18:04 +00:00
|
|
|
|
2021-09-12 03:15:12 +00:00
|
|
|
/**
|
|
|
|
* devfdt_get_addr_index_ptr() - Return indexed pointer to the address of 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
|
|
|
|
*
|
2022-01-12 09:55:41 +00:00
|
|
|
* Return: Pointer to addr, or NULL if there is no such property
|
2021-09-12 03:15:12 +00:00
|
|
|
*/
|
|
|
|
void *devfdt_get_addr_index_ptr(const struct udevice *dev, int index);
|
|
|
|
|
2017-05-17 23:18:04 +00:00
|
|
|
/**
|
2017-05-17 23:18:05 +00:00
|
|
|
* devfdt_get_addr_size_index() - Get the indexed reg property of a device
|
2017-05-17 23:18:04 +00:00
|
|
|
*
|
|
|
|
* 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
|
2023-04-21 15:33:58 +00:00
|
|
|
* @size: Pointer to size variable - this function returns the size
|
2017-05-17 23:18:04 +00:00
|
|
|
* specified in the 'reg' property here
|
|
|
|
*
|
2023-09-27 13:33:30 +00:00
|
|
|
* Return: Address, or FDT_ADDR_T_NONE if there is no such property
|
2017-05-17 23:18:04 +00:00
|
|
|
*/
|
2020-01-27 15:49:39 +00:00
|
|
|
fdt_addr_t devfdt_get_addr_size_index(const struct udevice *dev, int index,
|
|
|
|
fdt_size_t *size);
|
2017-05-17 23:18:04 +00:00
|
|
|
|
2023-04-21 15:33:58 +00:00
|
|
|
/**
|
|
|
|
* devfdt_get_addr_size_index_ptr() - Return indexed pointer to the address of 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 variable - this function returns the size
|
|
|
|
* specified in the 'reg' property here
|
|
|
|
*
|
|
|
|
* Return: Pointer to addr, or NULL if there is no such property
|
|
|
|
*/
|
|
|
|
void *devfdt_get_addr_size_index_ptr(const struct udevice *dev, int index,
|
|
|
|
fdt_size_t *size);
|
|
|
|
|
2017-05-17 23:18:04 +00:00
|
|
|
/**
|
2017-05-17 23:18:05 +00:00
|
|
|
* devfdt_get_addr_name() - Get the reg property of a device, indexed by name
|
2017-05-17 23:18:04 +00:00
|
|
|
*
|
|
|
|
* @dev: Pointer to a device
|
|
|
|
* @name: the 'reg' property can hold a list of <addr, size> pairs, with the
|
2023-09-27 13:33:30 +00:00
|
|
|
* 'reg-names' property providing named-based identification. @name
|
2017-05-17 23:18:04 +00:00
|
|
|
* indicates the value to search for in 'reg-names'.
|
|
|
|
*
|
2023-09-27 13:33:31 +00:00
|
|
|
* Return: Address, or FDT_ADDR_T_NONE if there is no such property
|
2017-05-17 23:18:04 +00:00
|
|
|
*/
|
2020-01-27 15:49:39 +00:00
|
|
|
fdt_addr_t devfdt_get_addr_name(const struct udevice *dev, const char *name);
|
2017-05-17 23:18:04 +00:00
|
|
|
|
2023-09-27 13:33:32 +00:00
|
|
|
/**
|
|
|
|
* devfdt_get_addr_name_ptr() - Get the reg property of a device as a pointer,
|
|
|
|
* 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. @name
|
|
|
|
* indicates the value to search for in 'reg-names'.
|
|
|
|
*
|
|
|
|
* Return: Pointer to addr, or NULL if there is no such property
|
|
|
|
*/
|
|
|
|
void *devfdt_get_addr_name_ptr(const struct udevice *dev, const char *name);
|
|
|
|
|
2019-08-01 13:42:56 +00:00
|
|
|
/**
|
|
|
|
* 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
|
2023-09-27 13:33:30 +00:00
|
|
|
* 'reg-names' property providing named-based identification. @name
|
2019-08-01 13:42:56 +00:00
|
|
|
* 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
|
|
|
|
*
|
2023-09-27 13:33:31 +00:00
|
|
|
* Return: Address, or FDT_ADDR_T_NONE if there is no such property
|
2019-08-01 13:42:56 +00:00
|
|
|
*/
|
2020-01-27 15:49:39 +00:00
|
|
|
fdt_addr_t devfdt_get_addr_size_name(const struct udevice *dev,
|
|
|
|
const char *name, fdt_size_t *size);
|
2019-08-01 13:42:56 +00:00
|
|
|
|
2023-09-27 13:33:32 +00:00
|
|
|
/**
|
|
|
|
* devfdt_get_addr_size_name_ptr() - Get the reg property for a device as a
|
|
|
|
* pointer, 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. @name
|
|
|
|
* 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: Pointer to addr, or NULL if there is no such property
|
|
|
|
*/
|
|
|
|
void *devfdt_get_addr_size_name_ptr(const struct udevice *dev,
|
|
|
|
const char *name, fdt_size_t *size);
|
|
|
|
|
2019-09-15 18:08:58 +00:00
|
|
|
/**
|
|
|
|
* devfdt_get_addr_pci() - Read an address and handle PCI address translation
|
|
|
|
*
|
|
|
|
* @dev: Device to read from
|
2023-09-26 14:14:58 +00:00
|
|
|
* @sizep: If non-NULL, returns size of address space
|
2022-01-12 09:55:41 +00:00
|
|
|
* Return: address or FDT_ADDR_T_NONE if not found
|
2019-09-15 18:08:58 +00:00
|
|
|
*/
|
2023-09-26 14:14:58 +00:00
|
|
|
fdt_addr_t devfdt_get_addr_pci(const struct udevice *dev, fdt_size_t *sizep);
|
2019-09-15 18:08:58 +00:00
|
|
|
|
2017-05-17 23:18:04 +00:00
|
|
|
#endif
|