* Written by Simon Glass <sjg@chromium.org>
*/
-#include <asm/types.h>
-#include <asm/io.h>
#include <common.h>
#include <dm.h>
-#include <mapmem.h>
#include <dm/of_access.h>
+#include <mapmem.h>
+#include <asm/global_data.h>
+#include <asm/types.h>
+#include <asm/io.h>
+#include <linux/ioport.h>
+
+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);
+}
int dev_read_u32(const struct udevice *dev, const char *propname, u32 *outp)
{
{
fdt_addr_t addr = dev_read_addr(dev);
- return (addr == FDT_ADDR_T_NONE) ? NULL : map_sysmem(addr, 0);
+ return (addr == FDT_ADDR_T_NONE) ? NULL : (void *)(uintptr_t)addr;
}
void *dev_remap_addr(const struct udevice *dev)
return ofnode_read_string_count(dev_ofnode(dev), propname);
}
+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);
+}
+
int dev_read_phandle_with_args(const struct udevice *dev, const char *list_name,
const char *cells_name, int cell_count,
int index, struct ofnode_phandle_args *out_args)
}
int dev_count_phandle_with_args(const struct udevice *dev,
- const char *list_name, const char *cells_name)
+ const char *list_name, const char *cells_name,
+ int cell_count)
{
return ofnode_count_phandle_with_args(dev_ofnode(dev), list_name,
- cells_name);
+ cells_name, cell_count);
}
int dev_read_addr_cells(const struct udevice *dev)
int dev_read_first_prop(const struct udevice *dev, struct ofprop *prop)
{
- return ofnode_get_first_property(dev_ofnode(dev), prop);
+ return ofnode_first_property(dev_ofnode(dev), prop);
}
int dev_read_next_prop(struct ofprop *prop)
{
- return ofnode_get_next_property(prop);
+ return ofnode_next_property(prop);
}
const void *dev_read_prop_by_prop(struct ofprop *prop,
const char **propname, int *lenp)
{
- return ofnode_get_property_by_prop(prop, propname, lenp);
+ return ofprop_get_property(prop, propname, lenp);
}
int dev_read_alias_seq(const struct udevice *dev, int *devnump)
{
ofnode node = dev_ofnode(dev);
const char *uc_name = dev->uclass->uc_drv->name;
- int ret;
+ int ret = -ENOTSUPP;
if (ofnode_is_np(node)) {
ret = of_alias_get_id(ofnode_to_np(node), uc_name);
- if (ret >= 0)
+ if (ret >= 0) {
*devnump = ret;
+ ret = 0;
+ }
} else {
+#if CONFIG_IS_ENABLED(OF_CONTROL)
ret = fdtdec_get_alias_seq(gd->fdt_blob, uc_name,
ofnode_to_offset(node), devnump);
+#endif
}
return ret;
return ofnode_translate_dma_address(dev_ofnode(dev), in_addr);
}
+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);
+}
+
int dev_read_alias_highest_id(const char *stem)
{
if (of_live_active())
{
return ofnode_get_child_count(dev_ofnode(dev));
}
+
+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;
+}
+
+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);
+}
+
+ofnode dev_get_phy_node(const struct udevice *dev)
+{
+ return ofnode_get_phy_node(dev_ofnode(dev));
+}
+
+phy_interface_t dev_read_phy_mode(const struct udevice *dev)
+{
+ return ofnode_read_phy_mode(dev_ofnode(dev));
+}