1. 04 11月, 2014 2 次提交
    • G
      of: Eliminate of_allnodes list · 5063e25a
      Grant Likely 提交于
      The device tree structure is composed of two lists; the 'allnodes' list
      which is a singly linked list containing every node in the tree, and the
      child->parent structure where each parent node has a singly linked list
      of children. All of the data in the allnodes list can be easily
      reproduced with the parent-child lists, so of_allnodes is actually
      unnecessary. Remove it entirely which saves a bit of memory and
      simplifies the data structure quite a lot.
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      Cc: Rob Herring <robh@kernel.org>
      Cc: Gaurav Minocha <gaurav.minocha.os@gmail.com>
      Cc: Pantelis Antoniou <pantelis@pantelis.antoniou@konsulko.com>
      5063e25a
    • G
      of: Fix overflow bug in string property parsing functions · a87fa1d8
      Grant Likely 提交于
      The string property read helpers will run off the end of the buffer if
      it is handed a malformed string property. Rework the parsers to make
      sure that doesn't happen. At the same time add new test cases to make
      sure the functions behave themselves.
      
      The original implementations of of_property_read_string_index() and
      of_property_count_strings() both open-coded the same block of parsing
      code, each with it's own subtly different bugs. The fix here merges
      functions into a single helper and makes the original functions static
      inline wrappers around the helper.
      
      One non-bugfix aspect of this patch is the addition of a new wrapper,
      of_property_read_string_array(). The new wrapper is needed by the
      device_properties feature that Rafael is working on and planning to
      merge for v3.19. The implementation is identical both with and without
      the new static inline wrapper, so it just got left in to reduce the
      churn on the header file.
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
      Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Darren Hart <darren.hart@intel.com>
      Cc: <stable@vger.kernel.org>  # v3.3+: Drop selftest hunks that don't apply
      a87fa1d8
  2. 30 10月, 2014 1 次提交
  3. 08 10月, 2014 1 次提交
    • P
      net: phy: adjust fixed_phy_register() return value · fd2ef0ba
      Petri Gynther 提交于
      Adjust fixed_phy_register() to return struct phy_device *, so that
      it becomes easy to use fixed PHYs without device tree support:
      
        phydev = fixed_phy_register(PHY_POLL, &fixed_phy_status, NULL);
        fixed_phy_set_link_update(phydev, fixed_phy_link_update);
        phy_connect_direct(netdev, phydev, handler_fn, phy_interface);
      
      This change is a prerequisite for modifying bcmgenet driver to work
      without a device tree on Broadcom's MIPS-based 7xxx platforms.
      Signed-off-by: NPetri Gynther <pgynther@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      fd2ef0ba
  4. 07 10月, 2014 1 次提交
  5. 05 10月, 2014 5 次提交
    • G
      of/selftest: Use the resolver to fixup phandles · 2eb46da2
      Grant Likely 提交于
      The selftest data ends up causing duplicate phandles in the live tree
      for the time that the testcase data is inserted into the live tree. This
      is obviously a bad situation because anything attempting to read the
      tree while the selftests are running make resolve phandles to one of the
      testcase data nodes. Fix the problem by using the of_resolve_phandles()
      function to eliminate duplicates.
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
      Cc: Gaurav Minocha <gaurav.minocha.os@gmail.com>
      2eb46da2
    • P
      of: Introduce Device Tree resolve support. · 7941b27b
      Pantelis Antoniou 提交于
      Introduce support for dynamic device tree resolution.
      Using it, it is possible to prepare a device tree that's
      been loaded on runtime to be modified and inserted at the kernel
      live tree.
      
      Export of of_resolve and bug fix of double free by
      	Guenter Roeck <groeck@juniper.net>
      Signed-off-by: NPantelis Antoniou <pantelis.antoniou@konsulko.com>
      [grant.likely: Don't need to select CONFIG_OF_DYNAMIC and CONFIG_OF_DEVICE]
      [grant.likely: Don't need to depend on OF or !SPARC]
      [grant.likely: Factor out duplicate code blocks into single function]
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      7941b27b
    • G
      of/selftest: Add a test for duplicate phandles · 841ec213
      Grant Likely 提交于
      All phandles in the tree should be unique. Add a testcase to make sure
      that this is so.
      
      Note: this testcase fails on the current kernel because the selftest
      code itself ends up adding duplicate phandles. Before this testcase is
      merged the selftest code needs to be modified to resolve phandles before
      adding them.
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
      841ec213
    • G
      of: Don't try to search when phandle == 0 · fc59b447
      Grant Likely 提交于
      A value of '0' isn't a valid phandle, so searching for a node with that
      phandle is pointless. It will result in nothing but false positives.
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      fc59b447
    • G
      of/selftest: Test structure of device tree · f2051d6a
      Grant Likely 提交于
      Add a testcase to verify that the device tree is properly constructed
      and the lists are in a correct order. The new testcase gets run twice;
      once after adding the testcase data, and once after removing it again.
      It is run twice to make sure adding and removing the testcase data
      doesn't corrupt the data structure.
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      Cc: Gaurav Minocha <gaurav.minocha.os@gmail.com>
      f2051d6a
  6. 02 10月, 2014 1 次提交
    • G
      of: Fix NULL dereference in selftest removal code · e66c98c7
      Grant Likely 提交于
      The selftest code removes its testcase data from the live tree when
      exiting, but if the testcases data tree contains an empty child of the
      root, then it causes an oops due to a NULL dereference. The reason is
      that the code tries to directly dereference the child pointer without
      checking first if a child is actually there.
      
      The solution is to pass the parent node into detach_node_and_children()
      instead of trying to pass the child. This required removing the code
      that attempts to remove all of the sibling nodes in
      detach_node_and_children(), which was never sensible in the first place.
      
      At the same time add a check to make sure the bounds of the nodes list
      are not exceeded by the testdata tree. If they are then abort.
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      Cc: Gaurav Minocha <gaurav.minocha.os@gmail.com>
      e66c98c7
  7. 01 10月, 2014 4 次提交
    • L
      of/pci: Add support for parsing PCI host bridge resources from DT · cbe4097f
      Liviu Dudau 提交于
      Provide a function to parse the PCI DT ranges that can be used to create a
      pci_host_bridge structure together with its associated bus.
      Signed-off-by: NLiviu Dudau <Liviu.Dudau@arm.com>
      [make io_base parameter optional]
      Signed-off-by: NRobert Richter <rrichter@cavium.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      CC: Arnd Bergmann <arnd@arndb.de>
      CC: Grant Likely <grant.likely@linaro.org>
      CC: Rob Herring <robh+dt@kernel.org>
      CC: Catalin Marinas <catalin.marinas@arm.com>
      cbe4097f
    • L
      of/pci: Add pci_get_new_domain_nr() and of_get_pci_domain_nr() · 41e5c0f8
      Liviu Dudau 提交于
      Add pci_get_new_domain_nr() to allocate a new domain number and
      of_get_pci_domain_nr() to retrieve the PCI domain number of a given device
      from DT.  Host bridge drivers or architecture-specific code can choose to
      implement their PCI domain number policy using these two functions.
      
      Using of_get_pci_domain_nr() guarantees a stable PCI domain number on every
      boot provided that all host bridge controllers are assigned a number in the
      device tree using "linux,pci-domain" property.  Mixing use of
      pci_get_new_domain_nr() and of_get_pci_domain_nr() is not recommended as it
      can lead to potentially conflicting domain numbers being assigned to root
      buses behind different host bridges.
      Signed-off-by: NLiviu Dudau <Liviu.Dudau@arm.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      CC: Arnd Bergmann <arnd@arndb.de>
      CC: Grant Likely <grant.likely@linaro.org>
      CC: Rob Herring <robh+dt@kernel.org>
      CC: Catalin Marinas <catalin.marinas@arm.com>
      41e5c0f8
    • L
      of/pci: Fix the conversion of IO ranges into IO resources · 0b0b0893
      Liviu Dudau 提交于
      The ranges property for a host bridge controller in DT describes the
      mapping between the PCI bus address and the CPU physical address.  The
      resources framework however expects that the IO resources start at a pseudo
      "port" address 0 (zero) and have a maximum size of IO_SPACE_LIMIT.  The
      conversion from PCI ranges to resources failed to take that into account,
      returning a CPU physical address instead of a port number.
      
      Also fix all the drivers that depend on the old behaviour by fetching the
      CPU physical address based on the port number where it is being needed.
      Signed-off-by: NLiviu Dudau <Liviu.Dudau@arm.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Acked-by: NLinus Walleij <linus.walleij@linaro.org>
      CC: Grant Likely <grant.likely@linaro.org>
      CC: Rob Herring <robh+dt@kernel.org>
      CC: Arnd Bergmann <arnd@arndb.de>
      CC: Thierry Reding <thierry.reding@gmail.com>
      CC: Simon Horman <horms@verge.net.au>
      CC: Catalin Marinas <catalin.marinas@arm.com>
      0b0b0893
    • L
      of/pci: Move of_pci_range_to_resource() to of/address.c · 83bbde1c
      Liviu Dudau 提交于
      We need to enhance of_pci_range_to_resources() enough that it won't make
      sense for it to be inline anymore.  Move it to drivers/of/address.c, under
      #ifdef CONFIG_PCI.
      
      of_address.h previously implemented of_pci_range_to_resources()
      unconditionally, regardless of any config options.  The implementation in
      address.c is defined only when CONFIG_OF_ADDRESS=y and CONFIG_PCI=y,
      so add a dummy version to avoid build errors when CONFIG_OF or
      CONFIG_OF_ADDRESS is not defined.
      
      [bhelgaas: drop extra detail from changelog, move def under CONFIG_PCI,
      add dummy of_pci_range_to_resource() for build errors (from Arnd)]
      Signed-off-by: NLiviu Dudau <Liviu.Dudau@arm.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      CC: Grant Likely <grant.likely@linaro.org>
      CC: Rob Herring <robh+dt@kernel.org>
      CC: Arnd Bergmann <arnd@arndb.de>
      CC: Catalin Marinas <catalin.marinas@arm.com>
      83bbde1c
  8. 30 9月, 2014 1 次提交
    • L
      of/pci: Add pci_register_io_range() and pci_pio_to_address() · 41f8bba7
      Liviu Dudau 提交于
      Some architectures do not have a simple view of the PCI I/O space and
      instead use a range of CPU addresses that map to bus addresses.  For some
      architectures these ranges will be expressed by OF bindings in a device
      tree file.
      
      This patch introduces a pci_register_io_range() helper function with a
      generic implementation that can be used by such architectures to keep track
      of the I/O ranges described by the PCI bindings.  If the PCI_IOBASE macro
      is not defined, that signals lack of support for PCI and we return an
      error.
      
      In order to retrieve the CPU address associated with an I/O port, a new
      helper function pci_pio_to_address() is introduced.  This will search in
      the list of ranges registered with pci_register_io_range() and return the
      CPU address that corresponds to the given port.
      
      [arnd: add dummy !CONFIG_OF pci_pio_to_address() to fix build errors]
      Signed-off-by: NLiviu Dudau <Liviu.Dudau@arm.com>
      Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: NCatalin Marinas <catalin.marinas@arm.com>
      Acked-by: NRob Herring <robh@kernel.org>
      CC: Grant Likely <grant.likely@linaro.org>
      41f8bba7
  9. 25 9月, 2014 1 次提交
    • S
      of/fdt: fix memory range check · 9aacd602
      Srinivas Kandagatla 提交于
      In cases where board has below memory DT node
      
      memory{
      	device_type = "memory";
      	reg = <0x80000000 0x80000000>;
      };
      
      Check on the memory range in fdt.c will always fail because it is
      comparing MAX_PHYS_ADDR with base + size, in fact it should compare
      it with base + size - 1.
      
      This issue was originally noticed on Qualcomm IFC6410 board.
      Without this patch kernel shows up noticed unnecessary warnings
      
      [    0.000000] Machine model: Qualcomm APQ8064/IFC6410
      [    0.000000] Ignoring memory range 0xffffffff - 0x100000000
      [    0.000000] cma: Reserved 64 MiB at ab800000
      
      as a result the size get reduced to 0x7fffffff which looks wrong.
      
      This patch fixes the check involved in generating this warning and
      as a result it also fixes the wrong size calculation.
      Signed-off-by: NSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
      [grant.likely: adjust new size calculation also]
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      9aacd602
  10. 22 9月, 2014 1 次提交
  11. 20 9月, 2014 1 次提交
    • F
      of: mdio: honor flags passed to of_phy_connect · 2f637151
      Florian Fainelli 提交于
      Commit f9a8f83b ("net: phy: remove flags argument from phy_{attach,
      connect, connect_direct}") removed the flags argument to the PHY library
      calls to: phy_{attach,connect,connect_direct}.
      
      Most Device Tree aware drivers call of_phy_connect() with the flag
      argument set to 0, but some of them might want to set a different value
      there in order for the PHY driver to key a specific behavior based on
      the phy_device::phy_flags value.
      
      Allow such drivers to set custom phy_flags as part of the
      of_phy_connect() call since of_phy_connect() does start the PHY state
      machine, it will call into the PHY driver config_init() callback which
      is usually where a specific phy_flags value is important.
      
      Fixes: f9a8f83b ("net: phy: remove flags argument from phy_{attach, connect, connect_direct}")
      Signed-off-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      2f637151
  12. 08 9月, 2014 4 次提交
  13. 16 8月, 2014 3 次提交
  14. 04 8月, 2014 1 次提交
    • G
      of: Fixing OF Selftest build error · 32147e9a
      Gaurav Minocha 提交于
      This patch is to fix following error while compiling OF selftests.
      "drivers/of/selftest.c:617:2: error: implicit declaration of function
      'of_fdt_unflatten_tree'"
      
      Now, CONFIG_OF_SELFTEST depends on CONFIG_OF_EARLY_FLATTREE so that the
      broken configuration cannot be selected. Ultimately it would be a good
      idea to allow CONFIG_OF_SELFTEST to select CONFIG_OF_EARLY_FLATTREE, but
      there is a dependency problem on i386 and x86_64 that causes dtc to not
      get built and causes the build to fail. That problem needs to be fixed
      first.
      Signed-off-by: NGaurav Minocha <gaurav.minocha.os@gmail.com>
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      32147e9a
  15. 02 8月, 2014 2 次提交
  16. 31 7月, 2014 1 次提交
  17. 30 7月, 2014 2 次提交
  18. 25 7月, 2014 1 次提交
    • G
      Adding selftest testdata dynamically into live tree · ae9304c9
      Gaurav Minocha 提交于
      This patch attaches selftest's device tree data (required by /drivers/of/selftest.c)
      dynamically into live device tree. First, it links selftest device tree data into the
      kernel image and then iterates over all the nodes and attaches them into the live tree.
      Once the testcases are complete, it removes the data attached.
      
      This patch will remove the manual process of addition and removal of selftest device
      tree data into the machine's dts file.
      
      Tested successfully with current selftest's testcases.
      Signed-off-by: NGaurav Minocha <gaurav.minocha.os@gmail.com>
      [glikely: Removed ability to build as a module and fixed no-devicetree bug]
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      ae9304c9
  19. 24 7月, 2014 5 次提交
    • P
      of: Transactional DT support. · 201c910b
      Pantelis Antoniou 提交于
      Introducing DT transactional support.
      
      A DT transaction is a method which allows one to apply changes
      in the live tree, in such a way that either the full set of changes
      take effect, or the state of the tree can be rolled-back to the
      state it was before it was attempted. An applied transaction
      can be rolled-back at any time.
      
      Documentation is in
      	Documentation/devicetree/changesets.txt
      Signed-off-by: NPantelis Antoniou <pantelis.antoniou@konsulko.com>
      [glikely: Removed device notifiers and reworked to be more consistent]
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      201c910b
    • G
      of: Reorder device tree changes and notifiers · 259092a3
      Grant Likely 提交于
      Currently, devicetree reconfig notifiers get emitted before the change
      is applied to the tree, but that behaviour is problematic if the
      receiver wants the determine the new state of the tree. The current
      users don't care, but the changeset code to follow will be making
      multiple changes at once. Reorder notifiers to get emitted after the
      change has been applied to the tree so that callbacks see the new tree
      state.
      
      At the same time, fixup the existing callbacks to expect the new order.
      There are a few callbacks that compare the old and new values of a
      changed property. Put both property pointers into the of_prop_reconfig
      structure.
      
      The current notifiers also allow the notifier callback to fail and
      cancel the change to the tree, but that feature isn't actually used.
      It really isn't valid to ignore a tree modification provided by firmware
      anyway, so remove the ability to cancel a change to the tree.
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      Cc: Nathan Fontenot <nfont@austin.ibm.com>
      259092a3
    • G
      of: Move dynamic node fixups out of powerpc and into common code · a25095d4
      Grant Likely 提交于
      PowerPC does an odd thing with dynamic nodes. It uses a notifier to
      catch new node additions and set some of the values like name and type.
      This makes no sense since that same code can be put directly into
      of_attach_node(). Besides, all dynamic node users need this, not just
      powerpc. Fix this problem by moving the logic out of arch/powerpc and
      into drivers/of/dynamic.c.
      
      It is also important to remove this notifier because we want to move the
      firing of notifiers from before the tree is modified to after so that
      the receiver gets a consistent view of the tree, but that is
      incompatible with notifiers that modify the node.
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      Cc: Nathan Fontenot <nfont@austin.ibm.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      a25095d4
    • G
      of: Make sure attached nodes don't carry along extra children · 6162dbe4
      Grant Likely 提交于
      The child pointer does not get cleared when attaching new nodes which
      could cause the tree to be inconsistent. Clear the child pointer in
      __of_attach_node() to be absolutely sure that the structure remains in a
      consistent layout.
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      6162dbe4
    • G
      of: Make devicetree sysfs update functions consistent. · 8a2b22a2
      Grant Likely 提交于
      All of the DT modification functions are split into two parts, the first
      part manipulates the DT data structure, and the second part updates
      sysfs, but the code isn't very consistent about how the second half is
      called. They don't all enforce the same rules about when it is valid to
      update sysfs, and there isn't any clarity on locking.
      
      The transactional DT modification feature that is coming also needs
      access to these functions so that it can perform all the structure
      changes together, and then all the sysfs updates as a second stage
      instead of doing each one at a time.
      
      Fix up the second have by creating a separate __of_*_sysfs() function
      for each of the helpers. The new functions have consistent naming (ie.
      of_node_add() becomes __of_attach_node_sysfs()) and all of them now
      defer if of_init hasn't been called yet.
      
      Callers of the new functions must hold the of_mutex to ensure there are
      no race conditions with of_init(). The mutex ensures that there will
      only ever be one writer to the tree at any given time. There can still
      be any number of readers and the raw_spin_lock is still used to make
      sure access to the data structure is still consistent.
      
      Finally, put the function prototypes into of_private.h so they are
      accessible to the transaction code.
      Signed-off-by: NPantelis Antoniou <pantelis.antoniou@konsulko.com>
      [grant.likely: Changed suffix from _post to _sysfs to match existing code]
      [grant.likely: Reorganized to eliminate trivial wrappers]
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      8a2b22a2
  20. 23 7月, 2014 1 次提交
  21. 16 7月, 2014 1 次提交
    • P
      of: Create unlocked versions of node and property add/remove functions · d8c50088
      Pantelis Antoniou 提交于
      The DT overlay code will need to manipulate nodes and properties while
      already holding the devicetree lock, or on nodes that are not yet
      attached to the tree, but the current helper functions don't allow that.
      Extract the core behaviour from the accessors and create the following
      unlocked variants.
      
      The unlocked variants require either the lock to already be held or for
      the nodes to be detached from the tree. Changes to live nodes will not
      get updated in sysfs, so the caller must arrange for housekeeping to
      take place after dropping the lock.
      
      The new functions are: __of_add_property(), __of_remove_property(),
      __of_update_property(), __of_attach_node() and __of_detach_node().
      Signed-off-by: NPantelis Antoniou <pantelis.antoniou@konsulko.com>
      [Remove unnecessary diff hunks and rewrite commit text]
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      d8c50088