Merge git://git.denx.de/u-boot-video
[oweals/u-boot.git] / include / dm / read.h
index d09b04d110a4649715d691ee98a199ea90b4ebfb..8114037e9771d1110b45a648f82cdf8358666bfb 100644 (file)
@@ -44,16 +44,6 @@ static inline bool dev_of_valid(struct udevice *dev)
        return ofnode_valid(dev_ofnode(dev));
 }
 
-/**
- * dev_read_resource() - obtain an indexed resource from a device.
- *
- * @dev: devuce to examine
- * @index index of the resource to retrieve (0 = first)
- * @res returns the resource
- * @return 0 if ok, negative on error
- */
-int dev_read_resource(struct udevice *dev, uint index, struct resource *res);
-
 #ifndef CONFIG_DM_DEV_READ_INLINE
 /**
  * dev_read_u32_default() - read a 32-bit integer from a device's DT property
@@ -122,6 +112,16 @@ fdt_addr_t dev_read_addr_index(struct udevice *dev, int index);
  */
 fdt_addr_t dev_read_addr(struct udevice *dev);
 
+/**
+ * dev_read_addr_ptr() - Get the reg property of a device
+ *                       as a pointer
+ *
+ * @dev: Device to read from
+ *
+ * @return pointer or NULL if not found
+ */
+void *dev_read_addr_ptr(struct udevice *dev);
+
 /**
  * dev_read_addr_size() - get address and size from a device property
  *
@@ -165,6 +165,29 @@ const char *dev_read_name(struct udevice *dev);
 int dev_read_stringlist_search(struct udevice *dev, const char *property,
                          const char *string);
 
+/**
+ * dev_read_string_index() - obtain an indexed string from a string list
+ *
+ * @dev: device to examine
+ * @propname: name of the property containing the string list
+ * @index: index of the string to return
+ * @out: return location for the string
+ *
+ * @return:
+ *   length of string, if found or -ve error value if not found
+ */
+int dev_read_string_index(struct udevice *dev, const char *propname, int index,
+                         const char **outp);
+
+/**
+ * dev_read_string_count() - find the number of strings in a string list
+ *
+ * @dev: device to examine
+ * @propname: name of the property containing the string list
+ * @return:
+ *   number of strings in the list, or -ve error value if not found
+ */
+int dev_read_string_count(struct udevice *dev, const char *propname);
 /**
  * dev_read_phandle_with_args() - Find a node pointed by phandle in a list
  *
@@ -284,7 +307,7 @@ int dev_read_phandle(struct udevice *dev);
  * @lenp: place to put length on success
  * @return pointer to property, or NULL if not found
  */
-const u32 *dev_read_prop(struct udevice *dev, const char *propname, int *lenp);
+const void *dev_read_prop(struct udevice *dev, const char *propname, int *lenp);
 
 /**
  * dev_read_alias_seq() - Get the alias sequence number of a node
@@ -366,6 +389,27 @@ const uint8_t *dev_read_u8_array_ptr(struct udevice *dev, const char *propname,
  */
 int dev_read_enabled(struct udevice *dev);
 
+/**
+ * dev_read_resource() - obtain an indexed resource from a device.
+ *
+ * @dev: device to examine
+ * @index index of the resource to retrieve (0 = first)
+ * @res returns the resource
+ * @return 0 if ok, negative on error
+ */
+int dev_read_resource(struct udevice *dev, uint index, struct resource *res);
+
+/**
+ * dev_read_resource_byname() - obtain a named resource from a device.
+ *
+ * @dev: device to examine
+ * @name: name of the resource to retrieve
+ * @res: returns the resource
+ * @return 0 if ok, negative on error
+ */
+int dev_read_resource_byname(struct udevice *dev, const char *name,
+                            struct resource *res);
+
 #else /* CONFIG_DM_DEV_READ_INLINE is enabled */
 
 static inline int dev_read_u32_default(struct udevice *dev,
@@ -406,6 +450,11 @@ static inline fdt_addr_t dev_read_addr(struct udevice *dev)
        return devfdt_get_addr(dev);
 }
 
+static inline void *dev_read_addr_ptr(struct udevice *dev)
+{
+       return devfdt_get_addr_ptr(dev);
+}
+
 static inline fdt_addr_t dev_read_addr_size(struct udevice *dev,
                                            const char *propname,
                                            fdt_size_t *sizep)
@@ -425,6 +474,19 @@ static inline int dev_read_stringlist_search(struct udevice *dev,
        return ofnode_stringlist_search(dev_ofnode(dev), propname, string);
 }
 
+static inline int dev_read_string_index(struct udevice *dev,
+                                       const char *propname, int index,
+                                       const char **outp)
+{
+       return ofnode_read_string_index(dev_ofnode(dev), propname, index, outp);
+}
+
+static inline int dev_read_string_count(struct udevice *dev,
+                                       const char *propname)
+{
+       return ofnode_read_string_count(dev_ofnode(dev), propname);
+}
+
 static inline int dev_read_phandle_with_args(struct udevice *dev,
                const char *list_name, const char *cells_name, int cell_count,
                int index, struct ofnode_phandle_args *out_args)
@@ -468,8 +530,8 @@ static inline int dev_read_phandle(struct udevice *dev)
        return fdt_get_phandle(gd->fdt_blob, dev_of_offset(dev));
 }
 
-static inline const u32 *dev_read_prop(struct udevice *dev,
-                                      const char *propname, int *lenp)
+static inline const void *dev_read_prop(struct udevice *dev,
+                                       const char *propname, int *lenp)
 {
        return ofnode_get_property(dev_ofnode(dev), propname, lenp);
 }
@@ -507,6 +569,19 @@ static inline int dev_read_enabled(struct udevice *dev)
        return fdtdec_get_is_enabled(gd->fdt_blob, dev_of_offset(dev));
 }
 
+static inline int dev_read_resource(struct udevice *dev, uint index,
+                                   struct resource *res)
+{
+       return ofnode_read_resource(dev_ofnode(dev), index, res);
+}
+
+static inline int dev_read_resource_byname(struct udevice *dev,
+                                          const char *name,
+                                          struct resource *res)
+{
+       return ofnode_read_resource_byname(dev_ofnode(dev), name, res);
+}
+
 #endif /* CONFIG_DM_DEV_READ_INLINE */
 
 /**