RT-Thread RTOS 1.2.0
An open source embedded real-time operating system
载入中...
搜索中...
未找到
ofw_io.h
浏览该文件的文档.
1/*
2 * Copyright (c) 2006-2022, RT-Thread Development Team
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Change Logs:
7 * Date Author Notes
8 * 2022-08-25 GuEe-GUI first version
9 */
10
11#ifndef __OFW_IO_H__
12#define __OFW_IO_H__
13
14#include <ioremap.h>
15#include <drivers/ofw.h>
16
21
23rt_err_t rt_ofw_get_address(struct rt_ofw_node *np, int index, rt_uint64_t *out_address, rt_uint64_t *out_size);
24rt_err_t rt_ofw_get_address_by_name(struct rt_ofw_node *np, const char *name,
25 rt_uint64_t *out_address, rt_uint64_t *out_size);
26int rt_ofw_get_address_array(struct rt_ofw_node *np, int nr, rt_uint64_t *out_regs);
27
28rt_uint64_t rt_ofw_translate_address(struct rt_ofw_node *np, const char *range_type, rt_uint64_t address);
29rt_uint64_t rt_ofw_reverse_address(struct rt_ofw_node *np, const char *range_type, rt_uint64_t address);
30
32{
33 rt_uint64_t bus_addr, cpu_addr;
34
35 bus_addr = rt_ofw_reverse_address(np, "dma-ranges", address);
36 cpu_addr = rt_ofw_translate_address(np, "ranges", bus_addr);
37
38 return cpu_addr != ~0ULL ? cpu_addr : address;
39}
40
42{
43 rt_uint64_t bus_addr, dma_addr;
44
45 bus_addr = rt_ofw_reverse_address(np, "ranges", address);
46 dma_addr = rt_ofw_translate_address(np, "dma-ranges", bus_addr);
47
48 return dma_addr != ~0ULL ? dma_addr : address;
49}
50
51void *rt_ofw_iomap(struct rt_ofw_node *np, int index);
52void *rt_ofw_iomap_by_name(struct rt_ofw_node *np, const char *name);
53
54#endif /* __OFW_IO_H__ */
void * rt_ofw_iomap(struct rt_ofw_node *np, int index)
rt_uint64_t rt_ofw_reverse_address(struct rt_ofw_node *np, const char *range_type, rt_uint64_t address)
rt_inline rt_uint64_t rt_ofw_translate_dma2cpu(struct rt_ofw_node *np, rt_uint64_t address)
int rt_ofw_bus_size_cells(struct rt_ofw_node *np)
void * rt_ofw_iomap_by_name(struct rt_ofw_node *np, const char *name)
rt_err_t rt_ofw_get_address_by_name(struct rt_ofw_node *np, const char *name, rt_uint64_t *out_address, rt_uint64_t *out_size)
rt_inline rt_uint64_t rt_ofw_translate_cpu2dma(struct rt_ofw_node *np, rt_uint64_t address)
rt_err_t rt_ofw_get_address(struct rt_ofw_node *np, int index, rt_uint64_t *out_address, rt_uint64_t *out_size)
int rt_ofw_io_size_cells(struct rt_ofw_node *np)
int rt_ofw_get_address_array(struct rt_ofw_node *np, int nr, rt_uint64_t *out_regs)
int rt_ofw_io_addr_cells(struct rt_ofw_node *np)
rt_uint64_t rt_ofw_translate_address(struct rt_ofw_node *np, const char *range_type, rt_uint64_t address)
int rt_ofw_get_address_count(struct rt_ofw_node *np)
int rt_ofw_bus_addr_cells(struct rt_ofw_node *np)
rt_base_t rt_err_t
unsigned long long rt_uint64_t