]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
Merge git://git.denx.de/u-boot-usb
authorTom Rini <trini@konsulko.com>
Sat, 29 Jul 2017 15:43:51 +0000 (11:43 -0400)
committerTom Rini <trini@konsulko.com>
Sat, 29 Jul 2017 15:43:51 +0000 (11:43 -0400)
1  2 
drivers/core/ofnode.c
include/dm/ofnode.h
include/dm/read.h

diff --combined drivers/core/ofnode.c
index c3fb0ae7b9124188d2f1d0e9b5a28300fa282027,5fc77c52a05356307fd434c1acbbd1c6a2c89ec6..c1a2e9f0daefdffef2b7087e91d5b23f86bb1c6e
@@@ -14,7 -14,6 +14,7 @@@
  #include <dm/of_addr.h>
  #include <dm/ofnode.h>
  #include <linux/err.h>
 +#include <linux/ioport.h>
  
  int ofnode_read_u32(ofnode node, const char *propname, u32 *outp)
  {
@@@ -199,14 -198,13 +199,14 @@@ fdt_addr_t ofnode_get_addr_index(ofnod
                const __be32 *prop_val;
                uint flags;
                u64 size;
 +              int na;
  
 -              prop_val = of_get_address(
 -                      (struct device_node *)ofnode_to_np(node), index,
 -                      &size, &flags);
 +              prop_val = of_get_address(ofnode_to_np(node), index, &size,
 +                                        &flags);
                if (!prop_val)
                        return FDT_ADDR_T_NONE;
 -              return  be32_to_cpup(prop_val);
 +              na = of_n_addr_cells(ofnode_to_np(node));
 +              return of_read_number(prop_val, na);
        } else {
                return fdt_get_base_address(gd->fdt_blob,
                                            ofnode_to_offset(node));
@@@ -315,6 -313,18 +315,18 @@@ int ofnode_parse_phandle_with_args(ofno
        return 0;
  }
  
+ int ofnode_count_phandle_with_args(ofnode node, const char *list_name,
+                                  const char *cells_name)
+ {
+       if (ofnode_is_np(node))
+               return of_count_phandle_with_args(ofnode_to_np(node),
+                               list_name, cells_name);
+       else
+               return fdtdec_parse_phandle_with_args(gd->fdt_blob,
+                               ofnode_to_offset(node), list_name, cells_name,
+                               0, -1, NULL);
+ }
  ofnode ofnode_path(const char *path)
  {
        if (of_live_active())
@@@ -595,23 -605,3 +607,23 @@@ bool ofnode_pre_reloc(ofnode node
  
        return false;
  }
 +
 +int ofnode_read_resource(ofnode node, uint index, struct resource *res)
 +{
 +      if (ofnode_is_np(node)) {
 +              return of_address_to_resource(ofnode_to_np(node), index, res);
 +      } else {
 +              struct fdt_resource fres;
 +              int ret;
 +
 +              ret = fdt_get_resource(gd->fdt_blob, ofnode_to_offset(node),
 +                                     "reg", index, &fres);
 +              if (ret < 0)
 +                      return -EINVAL;
 +              memset(res, '\0', sizeof(*res));
 +              res->start = fres.start;
 +              res->end = fres.end;
 +
 +              return 0;
 +      }
 +}
diff --combined include/dm/ofnode.h
index 966ca9309a3c776fbeb1385852b681b01f7f9ca3,8eecce59d1059a4f78564d216f0c2da91bc25537..210ddb2e5d7464573ef6d8c85cd0cd1d2a85291a
@@@ -15,8 -15,6 +15,8 @@@
  /* Enable checks to protect against invalid calls */
  #undef OF_CHECKS
  
 +struct resource;
 +
  /**
   * ofnode - reference to a device tree node
   *
@@@ -434,6 -432,23 +434,23 @@@ int ofnode_parse_phandle_with_args(ofno
                                   int index,
                                   struct ofnode_phandle_args *out_args);
  
+ /**
+  * ofnode_count_phandle_with_args() - Count number of phandle in a list
+  *
+  * This function is useful to count phandles into a list.
+  * Returns number of phandle on success, on error returns appropriate
+  * errno value.
+  *
+  * @node:     device tree node containing a list
+  * @list_name:        property name that contains a list
+  * @cells_name:       property name that specifies phandles' arguments count
+  * @return number of phandle on success, -ENOENT if @list_name does not
+  *      exist, -EINVAL if a phandle was not found, @cells_name could not
+  *      be found.
+  */
+ int ofnode_count_phandle_with_args(ofnode node, const char *list_name,
+                                  const char *cells_name);
  /**
   * ofnode_path() - find a node by full path
   *
@@@ -607,6 -622,4 +624,6 @@@ int ofnode_read_simple_size_cells(ofnod
   */
  bool ofnode_pre_reloc(ofnode node);
  
 +int ofnode_read_resource(ofnode node, uint index, struct resource *res);
 +
  #endif
diff --combined include/dm/read.h
index c2ca7ae34d4b48e31bcb4eba3a1d9c17cde35448,d09b04d110a4649715d691ee98a199ea90b4ebfb..c3a4a5611a70aad6fd7b4669524c0f2d461195dd
@@@ -44,6 -44,16 +44,6 @@@ static inline bool dev_of_valid(struct 
        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
@@@ -198,6 -208,24 +198,24 @@@ int dev_read_phandle_with_args(struct u
                                int index,
                                struct ofnode_phandle_args *out_args);
  
+ /**
+  * dev_count_phandle_with_args() - Return phandle number in a list
+  *
+  * This function is usefull to get phandle number contained in a property list.
+  * For example, this allows to allocate the right amount of memory to keep
+  * clock's reference contained into the "clocks" property.
+  *
+  *
+  * @dev:      device whose node containing a list
+  * @list_name:        property name that contains a list
+  * @cells_name:       property name that specifies phandles' arguments count
+  * @Returns number of phandle found on success, on error returns appropriate
+  * errno value.
+  */
+ int dev_count_phandle_with_args(struct udevice *dev, const char *list_name,
+                               const char *cells_name);
  /**
   * dev_read_addr_cells() - Get the number of address cells for a device's node
   *
@@@ -256,7 -284,7 +274,7 @@@ int dev_read_phandle(struct udevice *de
   * @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
@@@ -338,16 -366,6 +356,16 @@@ const uint8_t *dev_read_u8_array_ptr(st
   */
  int dev_read_enabled(struct udevice *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);
 +
  #else /* CONFIG_DM_DEV_READ_INLINE is enabled */
  
  static inline int dev_read_u32_default(struct udevice *dev,
@@@ -416,6 -434,13 +434,13 @@@ static inline int dev_read_phandle_with
                                              out_args);
  }
  
+ static inline int dev_count_phandle_with_args(struct udevice *dev,
+               const char *list_name, const char *cells_name)
+ {
+       return ofnode_count_phandle_with_args(dev_ofnode(dev), list_name,
+                                             cells_name);
+ }
  static inline int dev_read_addr_cells(struct udevice *dev)
  {
        /* NOTE: this call should walk up the parent stack */
@@@ -443,8 -468,8 +468,8 @@@ static inline int dev_read_phandle(stru
        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);
  }
@@@ -482,12 -507,6 +507,12 @@@ static inline int dev_read_enabled(stru
        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);
 +}
 +
  #endif /* CONFIG_DM_DEV_READ_INLINE */
  
  /**