aboutsummaryrefslogtreecommitdiff
path: root/core/device.c
AgeCommit message (Collapse)AuthorFilesLines
2017-06-27dt: Add phandle fixup helpersMadhavan Srinivasan1-0/+38
When there is a new device tree that needs to be added to the main dt of the opal (ex, IMC catalog dtb loaded from pnor partition), we need to check for the phandle values in the new incoming device tree before attaching it. Reason is that, incoming device tree could already have phandle values initialized for its nodes. Now, if we attach this new device tree to the main opal DT, we could potentially hit phandle duplicate error (since the phandles value usually start with 1). To avoid this, a new helper function dt_adjust_subtree_phandle() is added to scan the incoming device tree and update node "phandle" accordingly based on the opal "last_phandle" value. Add to this, helper function also supports updates of "properties" with in a node which may refer the "phandle" value in the incoming device tree. Helper function will also fix the "properties" field accordingly. Acked-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-06-27dt: Add helper function for last_phandle updatesMadhavan Srinivasan1-2/+2
Add helper functions for "last_phandle" access/update and modify functions to use helper functions. Acked-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-06-26Big log level reduction...Benjamin Herrenschmidt1-1/+1
90% of what we print isn't useful to a normal user. This dramatically reduces the amount of messages printed by OPAL in normal circumstances. We still need to add a way to bump the log level at boot based on a BMC scratch register or some HDAT property. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-04-07device: add dt_find_by_name_addrOliver O'Halloran1-0/+50
Adds two helper functions that allow device nodes to be found via their name and unit address. One will take an integer address and format it to a hex string while the other looks up the unit based a user supplied string. This is handy in a few places inside the HDAT parser. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-03-07device: implement dt_translate_address() properlyOliver O'Halloran1-2/+63
Currently this is implemented by calling dt_get_address() which only works when a device is a child of the root node. This patch implements the functionality to work with nested nodes when all parent nodes have an appropriate "ranges" property. This implementation only works for up to 64 bit addresses. Properly supporting larger addressing schemes is a fair amount of (probably pointless) work, so I'm leaving supporting that until we have an actual a need for it. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Tested-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2017-01-15dt: add dt_new_check()Oliver O'Halloran1-0/+14
This is similar to dt_new(), but if the node already exists it will return the existing node. This is useful because some init code depends on the presence of certain nodes, but where the node is actually created is unimportant. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-12-21Add fwts annotation for duplicate DT node entries.ppaidipe@linux.vnet.ibm.com1-1/+19
Reference bug: https://github.com/open-power/op-build/issues/751 Signed-off-by: Pridhiviraj Paidipeddi <ppaidipe@linux.vnet.ibm.com> [stewart@linux.vnet.ibm.com: tweak message slightly] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-10-14device: Add helper to delete a property by name if it existsBenjamin Herrenschmidt1-0/+8
This will be useful for fast reboot which needs to clean a few things up. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-09-27core/init: create the dt root in main_cpu_entryOliver O'Halloran1-2/+0
This is created seperately when parsing the hdat and when expanding the DT. There is no real reason for this and it makes more sense to create it in the main init path. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-07-06devicetree: Add dt_node_is_enabled()Benjamin Herrenschmidt1-0/+10
This accessor tests the "status" property allowing us to represent disabled devices in the device-tree. It will be used by PHB4 initially but its usage could be made more widespread. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Acked-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-01-21Merge branch 'stable'Stewart Smith1-4/+52
Merge device tree sorting
2016-01-21DT sorting testOliver O'Halloran1-1/+1
Moved the dt_dump() into test/dt_common.c so that it can be shared between hdata/test/hdata_to_dt.c and core/test/run-device.c run-device.c contains two tests, one basic sorting test and a generate-and-sort test. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> [stewart@linux.vnet.ibm.com: remove trailing whitespace] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-01-21core/device.c: Sort nodes with name@unit names by unitOliver O'Halloran1-4/+52
When unflattening (or building from hdat) a device tree child nodes are added in the order in which they are encountered. For nodes that have a <basename>@<unit> style name with a common basename it is useful to have them in the tree sorted by the unit in ascending order. Currently this requires the source data to present them in sorted order, but this isn't always the case. This patch modifies the node insertion process to insert new nodes in the correct location so the list of child nodes is sorted. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> [stewart@linux.vnet.ibm.com: remove trailing whitespace] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-11-12Fix resource leak on crash (similar to 125f95e)Stewart Smith1-1/+3
The error paths here are a bit suspicious anyway as we're allocating memory in a failure path for having failed to allocate memory. One can hope that the memory allocated to display the error is less than the memory we attempted to allocate in the first place. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-11-11Fix resource leak on crashStewart Smith1-1/+5
Even though we're heading to abort(), it seems like some static analysis checkers still think we're leaking. So.... well, let's just make them happy and free the memory. It's harmless to do that. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-08-17core: Add dt_copyJeremy Kerr1-0/+38
This change adds a new function to copy a device tree node to a new parent. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-07-08fix potential divide by zeroStewart Smith1-0/+4
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-06-19Verify zalloc returned valid pointerAnanth N Mavinakayanahalli1-0/+3
Else, we are dereferencing NULL Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-02-11core/device: Function to return child node using nameNeelesh Gupta1-0/+16
Add a function dt_find_by_name() that returns the child node if matches the given name, otherwise NULL. Signed-off-by: Neelesh Gupta <neelegup@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2014-12-02core/device: wrap a function to destroy a dt_nodeWei Yang1-8/+13
When destroying a dt_node, it needs to release both the name and itself. And there are several places to do the release. This patch wrap a function dt_destroy() to make sure both of the elements of a dt_node are released when it is not used any more. Signed-off-by: Wei Yang <weiyang@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2014-11-26abort if device tree parsing failsAnton Blanchard1-1/+2
I debugged a checkstop with a BML boot which turned out to be device tree issues. A corrupt device tree is very likely to result in a later checkstop, so abort in dt_expand to make debugging much easier. Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2014-07-02Initial commit of Open Source releaseBenjamin Herrenschmidt1-0/+791
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>