€•ÄJŒsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ,/translations/zh_CN/devicetree/overlay-notes”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/zh_TW/devicetree/overlay-notes”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/it_IT/devicetree/overlay-notes”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/ja_JP/devicetree/overlay-notes”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/ko_KR/devicetree/overlay-notes”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒPortuguese (Brazilian)”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/pt_BR/devicetree/overlay-notes”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/sp_SP/devicetree/overlay-notes”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒcomment”“”)”}”(hŒ SPDX-License-Identifier: GPL-2.0”h]”hŒ SPDX-License-Identifier: GPL-2.0”…””}”hh·sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1hµhhh²hh³ŒF/var/lib/git/docbuild/linux/Documentation/devicetree/overlay-notes.rst”h´KubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒDevicetree Overlay Notes”h]”hŒDevicetree Overlay Notes”…””}”(hhÏh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhhÊh²hh³hÇh´KubhŒ paragraph”“”)”}”(hŒÖThis document describes the implementation of the in-kernel device tree overlay functionality residing in drivers/of/overlay.c and is a companion document to Documentation/devicetree/dynamic-resolution-notes.rst[1]”h]”hŒÖThis document describes the implementation of the in-kernel device tree overlay functionality residing in drivers/of/overlay.c and is a companion document to Documentation/devicetree/dynamic-resolution-notes.rst[1]”…””}”(hhßh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KhhÊh²hubhÉ)”}”(hhh]”(hÎ)”}”(hŒHow overlays work”h]”hŒHow overlays work”…””}”(hhðh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhhíh²hh³hÇh´K ubhÞ)”}”(hX‘A Devicetree's overlay purpose is to modify the kernel's live tree, and have the modification affecting the state of the kernel in a way that is reflecting the changes. Since the kernel mainly deals with devices, any new device node that results in an active device should have it created while if the device node is either disabled or removed all together, the affected device should be deregistered.”h]”hX•A Devicetree’s overlay purpose is to modify the kernel’s live tree, and have the modification affecting the state of the kernel in a way that is reflecting the changes. Since the kernel mainly deals with devices, any new device node that results in an active device should have it created while if the device node is either disabled or removed all together, the affected device should be deregistered.”…””}”(hhþh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Khhíh²hubhÞ)”}”(hŒNLet's take an example where we have a foo board with the following base tree::”h]”hŒOLet’s take an example where we have a foo board with the following base tree:”…””}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Khhíh²hubhŒ literal_block”“”)”}”(hXõ---- foo.dts --------------------------------------------------------------- /* FOO platform */ /dts-v1/; / { compatible = "corp,foo"; /* shared resources */ res: res { }; /* On chip peripherals */ ocp: ocp { /* peripherals that are always instantiated */ peripheral1 { ... }; }; }; ---- foo.dts ---------------------------------------------------------------”h]”hXõ---- foo.dts --------------------------------------------------------------- /* FOO platform */ /dts-v1/; / { compatible = "corp,foo"; /* shared resources */ res: res { }; /* On chip peripherals */ ocp: ocp { /* peripherals that are always instantiated */ peripheral1 { ... }; }; }; ---- foo.dts ---------------------------------------------------------------”…””}”hjsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jh³hÇh´Khhíh²hubhÞ)”}”(hŒThe overlay bar.dtso, ::”h]”hŒThe overlay bar.dtso,”…””}”(hj*h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K)hhíh²hubj)”}”(hXw---- bar.dtso - overlay target location by label --------------------------- /dts-v1/; /plugin/; &ocp { /* bar peripheral */ bar { compatible = "corp,bar"; ... /* various properties and child nodes */ }; }; ---- bar.dtso --------------------------------------------------------------”h]”hXw---- bar.dtso - overlay target location by label --------------------------- /dts-v1/; /plugin/; &ocp { /* bar peripheral */ bar { compatible = "corp,bar"; ... /* various properties and child nodes */ }; }; ---- bar.dtso --------------------------------------------------------------”…””}”hj8sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jh³hÇh´K,hhíh²hubhÞ)”}”(hŒMwhen loaded (and resolved as described in [1]) should result in foo+bar.dts::”h]”hŒLwhen loaded (and resolved as described in [1]) should result in foo+bar.dts:”…””}”(hjFh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K8hhíh²hubj)”}”(hXÑ---- foo+bar.dts ----------------------------------------------------------- /* FOO platform + bar peripheral */ / { compatible = "corp,foo"; /* shared resources */ res: res { }; /* On chip peripherals */ ocp: ocp { /* peripherals that are always instantiated */ peripheral1 { ... }; /* bar peripheral */ bar { compatible = "corp,bar"; ... /* various properties and child nodes */ }; }; }; ---- foo+bar.dts -----------------------------------------------------------”h]”hXÑ---- foo+bar.dts ----------------------------------------------------------- /* FOO platform + bar peripheral */ / { compatible = "corp,foo"; /* shared resources */ res: res { }; /* On chip peripherals */ ocp: ocp { /* peripherals that are always instantiated */ peripheral1 { ... }; /* bar peripheral */ bar { compatible = "corp,bar"; ... /* various properties and child nodes */ }; }; }; ---- foo+bar.dts -----------------------------------------------------------”…””}”hjTsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jh³hÇh´K:hhíh²hubhÞ)”}”(hŒÂAs a result of the overlay, a new device node (bar) has been created so a bar platform device will be registered and if a matching device driver is loaded the device will be created as expected.”h]”hŒÂAs a result of the overlay, a new device node (bar) has been created so a bar platform device will be registered and if a matching device driver is loaded the device will be created as expected.”…””}”(hjbh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KQhhíh²hubhÞ)”}”(hXxIf the base DT was not compiled with the -@ option then the "&ocp" label will not be available to resolve the overlay node(s) to the proper location in the base DT. In this case, the target path can be provided. The target location by label syntax is preferred because the overlay can be applied to any base DT containing the label, no matter where the label occurs in the DT.”h]”hX|If the base DT was not compiled with the -@ option then the “&ocp†label will not be available to resolve the overlay node(s) to the proper location in the base DT. In this case, the target path can be provided. The target location by label syntax is preferred because the overlay can be applied to any base DT containing the label, no matter where the label occurs in the DT.”…””}”(hjph²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KUhhíh²hubhÞ)”}”(hŒBThe above bar.dtso example modified to use target path syntax is::”h]”hŒAThe above bar.dtso example modified to use target path syntax is:”…””}”(hj~h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K[hhíh²hubj)”}”(hXy---- bar.dtso - overlay target location by explicit path ------------------- /dts-v1/; /plugin/; &{/ocp} { /* bar peripheral */ bar { compatible = "corp,bar"; ... /* various properties and child nodes */ } }; ---- bar.dtso --------------------------------------------------------------”h]”hXy---- bar.dtso - overlay target location by explicit path ------------------- /dts-v1/; /plugin/; &{/ocp} { /* bar peripheral */ bar { compatible = "corp,bar"; ... /* various properties and child nodes */ } }; ---- bar.dtso --------------------------------------------------------------”…””}”hjŒsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆuh1jh³hÇh´K]hhíh²hubeh}”(h]”Œhow-overlays-work”ah ]”h"]”Œhow overlays work”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´K ubhÉ)”}”(hhh]”(hÎ)”}”(hŒOverlay in-kernel API”h]”hŒOverlay in-kernel API”…””}”(hj¥h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj¢h²hh³hÇh´KkubhÞ)”}”(hŒThe API is quite easy to use.”h]”hŒThe API is quite easy to use.”…””}”(hj³h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Kmhj¢h²hubhŒenumerated_list”“”)”}”(hhh]”(hŒ list_item”“”)”}”(hŒ‰Call of_overlay_fdt_apply() to create and apply an overlay changeset. The return value is an error or a cookie identifying this overlay. ”h]”hÞ)”}”(hŒˆCall of_overlay_fdt_apply() to create and apply an overlay changeset. The return value is an error or a cookie identifying this overlay.”h]”hŒˆCall of_overlay_fdt_apply() to create and apply an overlay changeset. The return value is an error or a cookie identifying this overlay.”…””}”(hjÌh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´KohjÈubah}”(h]”h ]”h"]”h$]”h&]”uh1jÆhjÃh²hh³hÇh´NubjÇ)”}”(hŒÓCall of_overlay_remove() to remove and clean up the overlay changeset previously created via the call to of_overlay_fdt_apply(). Removal of an overlay changeset that is stacked by another will not be permitted. ”h]”hÞ)”}”(hŒÒCall of_overlay_remove() to remove and clean up the overlay changeset previously created via the call to of_overlay_fdt_apply(). Removal of an overlay changeset that is stacked by another will not be permitted.”h]”hŒÒCall of_overlay_remove() to remove and clean up the overlay changeset previously created via the call to of_overlay_fdt_apply(). Removal of an overlay changeset that is stacked by another will not be permitted.”…””}”(hjäh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Krhjàubah}”(h]”h ]”h"]”h$]”h&]”uh1jÆhjÃh²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”Œenumtype”Œarabic”Œprefix”hŒsuffix”Œ)”uh1jÁhj¢h²hh³hÇh´KoubhÞ)”}”(hŒ‘Finally, if you need to remove all overlays in one-go, just call of_overlay_remove_all() which will remove every single one in the correct order.”h]”hŒ‘Finally, if you need to remove all overlays in one-go, just call of_overlay_remove_all() which will remove every single one in the correct order.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Kvhj¢h²hubhÞ)”}”(hŒ«There is the option to register notifiers that get called on overlay operations. See of_overlay_notifier_register/unregister and enum of_overlay_notify_action for details.”h]”hŒ«There is the option to register notifiers that get called on overlay operations. See of_overlay_notifier_register/unregister and enum of_overlay_notify_action for details.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Kzhj¢h²hubhÞ)”}”(hXÑA notifier callback for OF_OVERLAY_PRE_APPLY, OF_OVERLAY_POST_APPLY, or OF_OVERLAY_PRE_REMOVE may store pointers to a device tree node in the overlay or its content but these pointers must not persist past the notifier callback for OF_OVERLAY_POST_REMOVE. The memory containing the overlay will be kfree()ed after OF_OVERLAY_POST_REMOVE notifiers are called. Note that the memory will be kfree()ed even if the notifier for OF_OVERLAY_POST_REMOVE returns an error.”h]”hXÑA notifier callback for OF_OVERLAY_PRE_APPLY, OF_OVERLAY_POST_APPLY, or OF_OVERLAY_PRE_REMOVE may store pointers to a device tree node in the overlay or its content but these pointers must not persist past the notifier callback for OF_OVERLAY_POST_REMOVE. The memory containing the overlay will be kfree()ed after OF_OVERLAY_POST_REMOVE notifiers are called. Note that the memory will be kfree()ed even if the notifier for OF_OVERLAY_POST_REMOVE returns an error.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K~hj¢h²hubhÞ)”}”(hXThe changeset notifiers in drivers/of/dynamic.c are a second type of notifier that could be triggered by applying or removing an overlay. These notifiers are not allowed to store pointers to a device tree node in the overlay or its content. The overlay code does not protect against such pointers remaining active when the memory containing the overlay is freed as a result of removing the overlay.”h]”hXThe changeset notifiers in drivers/of/dynamic.c are a second type of notifier that could be triggered by applying or removing an overlay. These notifiers are not allowed to store pointers to a device tree node in the overlay or its content. The overlay code does not protect against such pointers remaining active when the memory containing the overlay is freed as a result of removing the overlay.”…””}”(hj-h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K†hj¢h²hubhÞ)”}”(hŒ§Any other code that retains a pointer to the overlay nodes or data is considered to be a bug because after removing the overlay the pointer will refer to freed memory.”h]”hŒ§Any other code that retains a pointer to the overlay nodes or data is considered to be a bug because after removing the overlay the pointer will refer to freed memory.”…””}”(hj;h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´Khj¢h²hubhÞ)”}”(hX¬Users of overlays must be especially aware of the overall operations that occur on the system to ensure that other kernel code does not retain any pointers to the overlay nodes or data. Any example of an inadvertent use of such pointers is if a driver or subsystem module is loaded after an overlay has been applied, and the driver or subsystem scans the entire devicetree or a large portion of it, including the overlay nodes.”h]”hX¬Users of overlays must be especially aware of the overall operations that occur on the system to ensure that other kernel code does not retain any pointers to the overlay nodes or data. Any example of an inadvertent use of such pointers is if a driver or subsystem module is loaded after an overlay has been applied, and the driver or subsystem scans the entire devicetree or a large portion of it, including the overlay nodes.”…””}”(hjIh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝh³hÇh´K‘hj¢h²hubeh}”(h]”Œoverlay-in-kernel-api”ah ]”h"]”Œoverlay in-kernel api”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´Kkubeh}”(h]”Œdevicetree-overlay-notes”ah ]”h"]”Œdevicetree overlay notes”ah$]”h&]”uh1hÈhhh²hh³hÇh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÇuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(hÍNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jŠŒerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÇŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(jdjajŸjœj\jYuŒ nametypes”}”(jd‰jŸ‰j\‰uh}”(jahÊjœhíjYj¢uŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”hŒsystem_message”“”)”}”(hhh]”hÞ)”}”(hŒfPossible title underline, too short for the title. Treating it as ordinary text because it's so short.”h]”hŒhPossible title underline, too short for the title. Treating it as ordinary text because it’s so short.”…””}”(hjñh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÝhjîubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”ŒINFO”Œline”K*Œsource”hÇuh1jìhhíh²hh³hÇh´K*ubaŒtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.