blob: 4c261e74951c0fb7cedebe7e95e8ba8a0bc0d8d3 [file] [log] [blame]
Kory Maincent2f84e9c2021-05-04 19:31:22 +02001.. SPDX-License-Identifier: GPL-2.0+
2.. Copyright 2021, Kory Maincent <kory.maincent@bootlin.com>
3
Heinrich Schuchardt60971e62024-01-14 14:53:13 +01004.. index::
5 single: extension (command)
6
Bin Meng830b5932022-03-27 22:20:44 +08007extension command
8=================
Kory Maincent2f84e9c2021-05-04 19:31:22 +02009
10Synopsis
11--------
12
13::
14
15 extension scan
16 extension list
17 extension apply <extension number|all>
18
19Description
20-----------
21
22The "extension" command proposes a generic U-Boot mechanism to detect
23extension boards connected to the HW platform, and apply the appropriate
24Device Tree overlays depending on the detected extension boards.
25
26The "extension" command comes with three sub-commands:
27
28 - "extension scan" makes the generic code call the board-specific
29 extension_board_scan() function to retrieve the list of detected
30 extension boards.
31
32 - "extension list" allows to list the detected extension boards.
33
34 - "extension apply <number>|all" allows to apply the Device Tree
35 overlay(s) corresponding to one, or all, extension boards
36
37The latter requires two environment variables to exist:
38
39 - extension_overlay_addr: the RAM address where to load the Device
40 Tree overlays
41
42 - extension_overlay_cmd: the U-Boot command to load one overlay.
43 Indeed, the location and mechanism to load DT overlays is very setup
44 specific.
45
46In order to enable this mechanism, board-specific code must implement
47the extension_board_scan() function that fills in a linked list of
48"struct extension", each describing one extension board. In addition,
49the board-specific code must select the SUPPORT_EXTENSION_SCAN Kconfig
50boolean.
51
52Usage example
53-------------
54
551. Make sure your devicetree is loaded and set as the working fdt tree.
56
57::
58
59 => run loadfdt
60 => fdt addr $fdtaddr
61
622. Prepare the environment variables
63
64::
65
66 => setenv extension_overlay_addr 0x88080000
67 => setenv extension_overlay_cmd 'load mmc 0:1 ${extension_overlay_addr} /boot/${extension_overlay_name}'
68
693. Detect the plugged extension board
70
71::
72
73 => extension scan
74
754. List the plugged extension board information and the devicetree
76 overlay name
77
78::
79
80 => extension list
81
825. Apply the appropriate devicetree overlay
83
84For apply the selected overlay:
85
86::
87
88 => extension apply 0
89
90For apply all the overlays:
91
92::
93
94 => extension apply all
95
96Simple extension_board_scan function example
97--------------------------------------------
98
99.. code-block:: c
100
101 int extension_board_scan(struct list_head *extension_list)
102 {
103 struct extension *extension;
104
105 extension = calloc(1, sizeof(struct extension));
106 snprintf(extension->overlay, sizeof(extension->overlay), "overlay.dtbo");
107 snprintf(extension->name, sizeof(extension->name), "extension board");
108 snprintf(extension->owner, sizeof(extension->owner), "sandbox");
109 snprintf(extension->version, sizeof(extension->version), "1.1");
110 snprintf(extension->other, sizeof(extension->other), "Extension board information");
111 list_add_tail(&extension->list, extension_list);
112
113 return 1;
114 }