2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2017-05-19 02:09:04 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2017 Google, Inc
|
|
|
|
* Written by Simon Glass <sjg@chromium.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
|
|
|
#include <dm/of_access.h>
|
2020-04-29 07:08:44 +00:00
|
|
|
#include <mapmem.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2020-04-29 07:08:44 +00:00
|
|
|
#include <asm/types.h>
|
|
|
|
#include <asm/io.h>
|
2020-08-05 11:56:11 +00:00
|
|
|
#include <linux/ioport.h>
|
2017-05-19 02:09:04 +00:00
|
|
|
|
2022-06-14 13:21:30 +00:00
|
|
|
int dev_read_u8(const struct udevice *dev, const char *propname, u8 *outp)
|
|
|
|
{
|
|
|
|
return ofnode_read_u8(dev_ofnode(dev), propname, outp);
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 dev_read_u8_default(const struct udevice *dev, const char *propname, u8 def)
|
|
|
|
{
|
|
|
|
return ofnode_read_u8_default(dev_ofnode(dev), propname, def);
|
|
|
|
}
|
|
|
|
|
|
|
|
int dev_read_u16(const struct udevice *dev, const char *propname, u16 *outp)
|
|
|
|
{
|
|
|
|
return ofnode_read_u16(dev_ofnode(dev), propname, outp);
|
|
|
|
}
|
|
|
|
|
|
|
|
u16 dev_read_u16_default(const struct udevice *dev, const char *propname,
|
|
|
|
u16 def)
|
|
|
|
{
|
|
|
|
return ofnode_read_u16_default(dev_ofnode(dev), propname, def);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
int dev_read_u32(const struct udevice *dev, const char *propname, u32 *outp)
|
2017-12-29 17:00:05 +00:00
|
|
|
{
|
|
|
|
return ofnode_read_u32(dev_ofnode(dev), propname, outp);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
int dev_read_u32_default(const struct udevice *dev, const char *propname,
|
|
|
|
int def)
|
2017-05-19 02:09:04 +00:00
|
|
|
{
|
|
|
|
return ofnode_read_u32_default(dev_ofnode(dev), propname, def);
|
|
|
|
}
|
|
|
|
|
2020-03-29 16:04:41 +00:00
|
|
|
int dev_read_u32_index(struct udevice *dev, const char *propname, int index,
|
|
|
|
u32 *outp)
|
|
|
|
{
|
|
|
|
return ofnode_read_u32_index(dev_ofnode(dev), propname, index, outp);
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 dev_read_u32_index_default(struct udevice *dev, const char *propname,
|
|
|
|
int index, u32 def)
|
|
|
|
{
|
|
|
|
return ofnode_read_u32_index_default(dev_ofnode(dev), propname, index,
|
|
|
|
def);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
int dev_read_s32(const struct udevice *dev, const char *propname, s32 *outp)
|
2018-12-10 17:37:37 +00:00
|
|
|
{
|
|
|
|
return ofnode_read_u32(dev_ofnode(dev), propname, (u32 *)outp);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
int dev_read_s32_default(const struct udevice *dev, const char *propname,
|
|
|
|
int def)
|
2018-12-10 17:37:37 +00:00
|
|
|
{
|
|
|
|
return ofnode_read_u32_default(dev_ofnode(dev), propname, def);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
int dev_read_u32u(const struct udevice *dev, const char *propname, uint *outp)
|
2018-12-10 17:37:37 +00:00
|
|
|
{
|
|
|
|
u32 val;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = ofnode_read_u32(dev_ofnode(dev), propname, &val);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
*outp = val;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
int dev_read_u64(const struct udevice *dev, const char *propname, u64 *outp)
|
2019-09-02 14:34:30 +00:00
|
|
|
{
|
|
|
|
return ofnode_read_u64(dev_ofnode(dev), propname, outp);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
u64 dev_read_u64_default(const struct udevice *dev, const char *propname,
|
|
|
|
u64 def)
|
2019-09-02 14:34:30 +00:00
|
|
|
{
|
|
|
|
return ofnode_read_u64_default(dev_ofnode(dev), propname, def);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
const char *dev_read_string(const struct udevice *dev, const char *propname)
|
2017-05-19 02:09:04 +00:00
|
|
|
{
|
|
|
|
return ofnode_read_string(dev_ofnode(dev), propname);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
bool dev_read_bool(const struct udevice *dev, const char *propname)
|
2017-05-19 02:09:04 +00:00
|
|
|
{
|
|
|
|
return ofnode_read_bool(dev_ofnode(dev), propname);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
ofnode dev_read_subnode(const struct udevice *dev, const char *subnode_name)
|
2017-05-19 02:09:04 +00:00
|
|
|
{
|
|
|
|
return ofnode_find_subnode(dev_ofnode(dev), subnode_name);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
ofnode dev_read_first_subnode(const struct udevice *dev)
|
2017-05-19 02:09:04 +00:00
|
|
|
{
|
|
|
|
return ofnode_first_subnode(dev_ofnode(dev));
|
|
|
|
}
|
|
|
|
|
|
|
|
ofnode dev_read_next_subnode(ofnode node)
|
|
|
|
{
|
|
|
|
return ofnode_next_subnode(node);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
int dev_read_size(const struct udevice *dev, const char *propname)
|
2017-05-19 02:09:04 +00:00
|
|
|
{
|
|
|
|
return ofnode_read_size(dev_ofnode(dev), propname);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
fdt_addr_t dev_read_addr_index(const struct udevice *dev, int index)
|
2017-05-19 02:09:04 +00:00
|
|
|
{
|
|
|
|
if (ofnode_is_np(dev_ofnode(dev)))
|
|
|
|
return ofnode_get_addr_index(dev_ofnode(dev), index);
|
|
|
|
else
|
|
|
|
return devfdt_get_addr_index(dev, index);
|
|
|
|
}
|
|
|
|
|
2023-03-13 00:31:25 +00:00
|
|
|
void *dev_read_addr_index_ptr(const struct udevice *dev, int index)
|
|
|
|
{
|
|
|
|
fdt_addr_t addr = dev_read_addr_index(dev, index);
|
|
|
|
|
|
|
|
if (addr == FDT_ADDR_T_NONE)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return map_sysmem(addr, 0);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
fdt_addr_t dev_read_addr_size_index(const struct udevice *dev, int index,
|
2019-08-01 13:42:56 +00:00
|
|
|
fdt_size_t *size)
|
|
|
|
{
|
|
|
|
if (ofnode_is_np(dev_ofnode(dev)))
|
|
|
|
return ofnode_get_addr_size_index(dev_ofnode(dev), index, size);
|
|
|
|
else
|
|
|
|
return devfdt_get_addr_size_index(dev, index, size);
|
|
|
|
}
|
|
|
|
|
2023-07-22 13:30:15 +00:00
|
|
|
void *dev_read_addr_size_index_ptr(const struct udevice *dev, int index,
|
|
|
|
fdt_size_t *size)
|
|
|
|
{
|
|
|
|
fdt_addr_t addr = dev_read_addr_size_index(dev, index, size);
|
|
|
|
|
|
|
|
if (addr == FDT_ADDR_T_NONE)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return map_sysmem(addr, 0);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
void *dev_remap_addr_index(const struct udevice *dev, int index)
|
2018-04-29 19:56:54 +00:00
|
|
|
{
|
|
|
|
fdt_addr_t addr = dev_read_addr_index(dev, index);
|
|
|
|
|
|
|
|
if (addr == FDT_ADDR_T_NONE)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return map_physmem(addr, 0, MAP_NOCACHE);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
fdt_addr_t dev_read_addr_name(const struct udevice *dev, const char *name)
|
2018-12-03 18:37:09 +00:00
|
|
|
{
|
|
|
|
int index = dev_read_stringlist_search(dev, "reg-names", name);
|
|
|
|
|
|
|
|
if (index < 0)
|
|
|
|
return FDT_ADDR_T_NONE;
|
|
|
|
else
|
|
|
|
return dev_read_addr_index(dev, index);
|
|
|
|
}
|
|
|
|
|
2023-09-27 13:33:32 +00:00
|
|
|
void *dev_read_addr_name_ptr(const struct udevice *dev, const char *name)
|
|
|
|
{
|
|
|
|
fdt_addr_t addr = dev_read_addr_name(dev, name);
|
|
|
|
|
|
|
|
if (addr == FDT_ADDR_T_NONE)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return map_sysmem(addr, 0);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
fdt_addr_t dev_read_addr_size_name(const struct udevice *dev, const char *name,
|
2019-08-01 13:42:56 +00:00
|
|
|
fdt_size_t *size)
|
|
|
|
{
|
|
|
|
int index = dev_read_stringlist_search(dev, "reg-names", name);
|
|
|
|
|
|
|
|
if (index < 0)
|
|
|
|
return FDT_ADDR_T_NONE;
|
|
|
|
else
|
|
|
|
return dev_read_addr_size_index(dev, index, size);
|
|
|
|
}
|
|
|
|
|
2023-09-27 13:33:32 +00:00
|
|
|
void *dev_read_addr_size_name_ptr(const struct udevice *dev, const char *name,
|
|
|
|
fdt_size_t *size)
|
|
|
|
{
|
|
|
|
fdt_addr_t addr = dev_read_addr_size_name(dev, name, size);
|
|
|
|
|
|
|
|
if (addr == FDT_ADDR_T_NONE)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return map_sysmem(addr, 0);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
void *dev_remap_addr_name(const struct udevice *dev, const char *name)
|
2018-12-03 18:37:09 +00:00
|
|
|
{
|
|
|
|
fdt_addr_t addr = dev_read_addr_name(dev, name);
|
|
|
|
|
|
|
|
if (addr == FDT_ADDR_T_NONE)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return map_physmem(addr, 0, MAP_NOCACHE);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
fdt_addr_t dev_read_addr(const struct udevice *dev)
|
2017-05-19 02:09:04 +00:00
|
|
|
{
|
|
|
|
return dev_read_addr_index(dev, 0);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
void *dev_read_addr_ptr(const struct udevice *dev)
|
2017-09-11 20:04:12 +00:00
|
|
|
{
|
|
|
|
fdt_addr_t addr = dev_read_addr(dev);
|
|
|
|
|
2023-03-13 00:31:25 +00:00
|
|
|
if (addr == FDT_ADDR_T_NONE)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return map_sysmem(addr, 0);
|
2017-09-11 20:04:12 +00:00
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
void *dev_remap_addr(const struct udevice *dev)
|
2018-04-29 19:56:54 +00:00
|
|
|
{
|
|
|
|
return dev_remap_addr_index(dev, 0);
|
|
|
|
}
|
|
|
|
|
2023-06-01 14:11:19 +00:00
|
|
|
fdt_addr_t dev_read_addr_size(const struct udevice *dev, fdt_size_t *sizep)
|
2017-05-19 02:09:04 +00:00
|
|
|
{
|
2023-06-01 14:11:19 +00:00
|
|
|
return dev_read_addr_size_index(dev, 0, sizep);
|
2017-05-19 02:09:04 +00:00
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
const char *dev_read_name(const struct udevice *dev)
|
2017-05-19 02:09:04 +00:00
|
|
|
{
|
|
|
|
return ofnode_get_name(dev_ofnode(dev));
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
int dev_read_stringlist_search(const struct udevice *dev, const char *property,
|
2018-01-15 10:07:18 +00:00
|
|
|
const char *string)
|
2017-05-19 02:09:04 +00:00
|
|
|
{
|
|
|
|
return ofnode_stringlist_search(dev_ofnode(dev), property, string);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
int dev_read_string_index(const struct udevice *dev, const char *propname,
|
|
|
|
int index, const char **outp)
|
2017-09-21 15:03:09 +00:00
|
|
|
{
|
|
|
|
return ofnode_read_string_index(dev_ofnode(dev), propname, index, outp);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
int dev_read_string_count(const struct udevice *dev, const char *propname)
|
2017-09-21 15:03:09 +00:00
|
|
|
{
|
|
|
|
return ofnode_read_string_count(dev_ofnode(dev), propname);
|
|
|
|
}
|
|
|
|
|
2021-10-23 23:26:07 +00:00
|
|
|
int dev_read_string_list(const struct udevice *dev, const char *propname,
|
|
|
|
const char ***listp)
|
|
|
|
{
|
|
|
|
return ofnode_read_string_list(dev_ofnode(dev), propname, listp);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
int dev_read_phandle_with_args(const struct udevice *dev, const char *list_name,
|
2018-01-15 10:07:18 +00:00
|
|
|
const char *cells_name, int cell_count,
|
|
|
|
int index, struct ofnode_phandle_args *out_args)
|
2017-05-19 02:09:04 +00:00
|
|
|
{
|
|
|
|
return ofnode_parse_phandle_with_args(dev_ofnode(dev), list_name,
|
|
|
|
cells_name, cell_count, index,
|
|
|
|
out_args);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
int dev_count_phandle_with_args(const struct udevice *dev,
|
2020-09-25 07:41:14 +00:00
|
|
|
const char *list_name, const char *cells_name,
|
|
|
|
int cell_count)
|
2017-11-29 08:06:10 +00:00
|
|
|
{
|
|
|
|
return ofnode_count_phandle_with_args(dev_ofnode(dev), list_name,
|
2020-09-25 07:41:14 +00:00
|
|
|
cells_name, cell_count);
|
2017-11-29 08:06:10 +00:00
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
int dev_read_addr_cells(const struct udevice *dev)
|
2017-05-19 02:09:04 +00:00
|
|
|
{
|
|
|
|
return ofnode_read_addr_cells(dev_ofnode(dev));
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
int dev_read_size_cells(const struct udevice *dev)
|
2017-05-19 02:09:04 +00:00
|
|
|
{
|
|
|
|
return ofnode_read_size_cells(dev_ofnode(dev));
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
int dev_read_simple_addr_cells(const struct udevice *dev)
|
2017-06-12 12:21:31 +00:00
|
|
|
{
|
|
|
|
return ofnode_read_simple_addr_cells(dev_ofnode(dev));
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
int dev_read_simple_size_cells(const struct udevice *dev)
|
2017-06-12 12:21:31 +00:00
|
|
|
{
|
|
|
|
return ofnode_read_simple_size_cells(dev_ofnode(dev));
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
int dev_read_phandle(const struct udevice *dev)
|
2017-05-19 02:09:04 +00:00
|
|
|
{
|
|
|
|
ofnode node = dev_ofnode(dev);
|
|
|
|
|
|
|
|
if (ofnode_is_np(node))
|
|
|
|
return ofnode_to_np(node)->phandle;
|
|
|
|
else
|
|
|
|
return fdt_get_phandle(gd->fdt_blob, ofnode_to_offset(node));
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
const void *dev_read_prop(const struct udevice *dev, const char *propname,
|
|
|
|
int *lenp)
|
2017-05-19 02:09:04 +00:00
|
|
|
{
|
2017-06-22 07:54:05 +00:00
|
|
|
return ofnode_get_property(dev_ofnode(dev), propname, lenp);
|
2017-05-19 02:09:04 +00:00
|
|
|
}
|
|
|
|
|
2020-01-13 10:34:56 +00:00
|
|
|
int dev_read_first_prop(const struct udevice *dev, struct ofprop *prop)
|
|
|
|
{
|
2022-09-07 02:27:13 +00:00
|
|
|
return ofnode_first_property(dev_ofnode(dev), prop);
|
2020-01-13 10:34:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int dev_read_next_prop(struct ofprop *prop)
|
|
|
|
{
|
2022-09-07 02:27:13 +00:00
|
|
|
return ofnode_next_property(prop);
|
2020-01-13 10:34:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const void *dev_read_prop_by_prop(struct ofprop *prop,
|
|
|
|
const char **propname, int *lenp)
|
|
|
|
{
|
2022-09-07 02:27:14 +00:00
|
|
|
return ofprop_get_property(prop, propname, lenp);
|
2020-01-13 10:34:56 +00:00
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
int dev_read_alias_seq(const struct udevice *dev, int *devnump)
|
2017-05-19 02:09:04 +00:00
|
|
|
{
|
|
|
|
ofnode node = dev_ofnode(dev);
|
|
|
|
const char *uc_name = dev->uclass->uc_drv->name;
|
2019-05-20 00:44:57 +00:00
|
|
|
int ret = -ENOTSUPP;
|
2017-05-19 02:09:04 +00:00
|
|
|
|
|
|
|
if (ofnode_is_np(node)) {
|
|
|
|
ret = of_alias_get_id(ofnode_to_np(node), uc_name);
|
2020-12-17 04:20:12 +00:00
|
|
|
if (ret >= 0) {
|
2017-05-19 02:09:04 +00:00
|
|
|
*devnump = ret;
|
2020-12-17 04:20:12 +00:00
|
|
|
ret = 0;
|
|
|
|
}
|
2017-05-19 02:09:04 +00:00
|
|
|
} else {
|
2019-05-20 00:44:57 +00:00
|
|
|
#if CONFIG_IS_ENABLED(OF_CONTROL)
|
2017-05-19 02:09:04 +00:00
|
|
|
ret = fdtdec_get_alias_seq(gd->fdt_blob, uc_name,
|
|
|
|
ofnode_to_offset(node), devnump);
|
2019-05-20 00:44:57 +00:00
|
|
|
#endif
|
2017-05-19 02:09:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
int dev_read_u32_array(const struct udevice *dev, const char *propname,
|
2017-05-19 02:09:04 +00:00
|
|
|
u32 *out_values, size_t sz)
|
|
|
|
{
|
|
|
|
return ofnode_read_u32_array(dev_ofnode(dev), propname, out_values, sz);
|
|
|
|
}
|
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
const uint8_t *dev_read_u8_array_ptr(const struct udevice *dev,
|
|
|
|
const char *propname, size_t sz)
|
2017-05-19 02:09:04 +00:00
|
|
|
{
|
|
|
|
return ofnode_read_u8_array_ptr(dev_ofnode(dev), propname, sz);
|
|
|
|
}
|
2017-06-12 12:21:30 +00:00
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
int dev_read_enabled(const struct udevice *dev)
|
2017-06-12 12:21:30 +00:00
|
|
|
{
|
|
|
|
ofnode node = dev_ofnode(dev);
|
|
|
|
|
|
|
|
if (ofnode_is_np(node))
|
|
|
|
return of_device_is_available(ofnode_to_np(node));
|
|
|
|
else
|
|
|
|
return fdtdec_get_is_enabled(gd->fdt_blob,
|
|
|
|
ofnode_to_offset(node));
|
|
|
|
}
|
2017-07-25 14:29:55 +00:00
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
int dev_read_resource(const struct udevice *dev, uint index,
|
|
|
|
struct resource *res)
|
2017-07-25 14:29:55 +00:00
|
|
|
{
|
|
|
|
return ofnode_read_resource(dev_ofnode(dev), index, res);
|
|
|
|
}
|
2017-08-25 16:12:30 +00:00
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
int dev_read_resource_byname(const struct udevice *dev, const char *name,
|
2017-08-25 16:12:30 +00:00
|
|
|
struct resource *res)
|
|
|
|
{
|
|
|
|
return ofnode_read_resource_byname(dev_ofnode(dev), name, res);
|
|
|
|
}
|
2018-01-15 10:07:19 +00:00
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
u64 dev_translate_address(const struct udevice *dev, const fdt32_t *in_addr)
|
2018-01-15 10:07:19 +00:00
|
|
|
{
|
|
|
|
return ofnode_translate_address(dev_ofnode(dev), in_addr);
|
|
|
|
}
|
2019-01-31 15:30:59 +00:00
|
|
|
|
2020-01-27 15:49:40 +00:00
|
|
|
u64 dev_translate_dma_address(const struct udevice *dev, const fdt32_t *in_addr)
|
2019-05-31 13:11:30 +00:00
|
|
|
{
|
|
|
|
return ofnode_translate_dma_address(dev_ofnode(dev), in_addr);
|
|
|
|
}
|
|
|
|
|
2021-01-12 12:55:22 +00:00
|
|
|
int dev_get_dma_range(const struct udevice *dev, phys_addr_t *cpu,
|
|
|
|
dma_addr_t *bus, u64 *size)
|
|
|
|
{
|
|
|
|
return ofnode_get_dma_range(dev_ofnode(dev), cpu, bus, size);
|
|
|
|
}
|
|
|
|
|
2019-01-31 15:30:59 +00:00
|
|
|
int dev_read_alias_highest_id(const char *stem)
|
|
|
|
{
|
|
|
|
if (of_live_active())
|
|
|
|
return of_alias_get_highest_id(stem);
|
|
|
|
|
|
|
|
return fdtdec_get_alias_highest_id(gd->fdt_blob, stem);
|
|
|
|
}
|
2019-09-15 18:08:58 +00:00
|
|
|
|
2023-09-26 14:14:58 +00:00
|
|
|
fdt_addr_t dev_read_addr_pci(const struct udevice *dev, fdt_size_t *sizep)
|
2019-09-15 18:08:58 +00:00
|
|
|
{
|
|
|
|
ulong addr;
|
|
|
|
|
|
|
|
addr = dev_read_addr(dev);
|
2023-09-26 14:14:58 +00:00
|
|
|
if (sizep)
|
|
|
|
*sizep = 0;
|
2019-09-15 18:08:58 +00:00
|
|
|
if (addr == FDT_ADDR_T_NONE && !of_live_active())
|
2023-09-26 14:14:58 +00:00
|
|
|
addr = devfdt_get_addr_pci(dev, sizep);
|
2019-09-15 18:08:58 +00:00
|
|
|
|
|
|
|
return addr;
|
|
|
|
}
|
2020-05-02 09:35:09 +00:00
|
|
|
|
|
|
|
int dev_get_child_count(const struct udevice *dev)
|
|
|
|
{
|
|
|
|
return ofnode_get_child_count(dev_ofnode(dev));
|
|
|
|
}
|
2020-08-05 11:56:11 +00:00
|
|
|
|
|
|
|
int dev_read_pci_bus_range(const struct udevice *dev,
|
|
|
|
struct resource *res)
|
|
|
|
{
|
|
|
|
const u32 *values;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
values = dev_read_prop(dev, "bus-range", &len);
|
|
|
|
if (!values || len < sizeof(*values) * 2)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
res->start = *values++;
|
|
|
|
res->end = *values;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2020-12-29 23:16:26 +00:00
|
|
|
|
|
|
|
int dev_decode_display_timing(const struct udevice *dev, int index,
|
|
|
|
struct display_timing *config)
|
|
|
|
{
|
|
|
|
return ofnode_decode_display_timing(dev_ofnode(dev), index, config);
|
|
|
|
}
|
2022-04-06 22:32:57 +00:00
|
|
|
|
2023-01-31 10:05:14 +00:00
|
|
|
int dev_decode_panel_timing(const struct udevice *dev,
|
|
|
|
struct display_timing *config)
|
|
|
|
{
|
|
|
|
return ofnode_decode_panel_timing(dev_ofnode(dev), config);
|
|
|
|
}
|
|
|
|
|
2022-04-06 22:32:57 +00:00
|
|
|
ofnode dev_get_phy_node(const struct udevice *dev)
|
|
|
|
{
|
|
|
|
return ofnode_get_phy_node(dev_ofnode(dev));
|
|
|
|
}
|
2022-04-06 22:33:01 +00:00
|
|
|
|
|
|
|
phy_interface_t dev_read_phy_mode(const struct udevice *dev)
|
|
|
|
{
|
|
|
|
return ofnode_read_phy_mode(dev_ofnode(dev));
|
|
|
|
}
|