Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/tegra: Obtain head number from DT

The head number of a given display controller is fixed in hardware and
required to program outputs appropriately. Relying on the driver probe
order to determine this number will not work, since that could yield a
situation where the second head was probed first and would be assigned
head number 0 instead of 1.

By explicitly specifying the head number in the device tree, it is no
longer necessary to rely on these assumptions. As a fallback, if the
property isn't available, derive the head number from the display
controller node's position in the device tree. That's somewhat more
reliable than the previous default but not a proper solution.

Tested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>

+42 -2
+3
Documentation/devicetree/bindings/gpu/nvidia,tegra20-host1x.txt
··· 118 118 See ../reset/reset.txt for details. 119 119 - reset-names: Must include the following entries: 120 120 - dc 121 + - nvidia,head: The number of the display controller head. This is used to 122 + setup the various types of output to receive video data from the given 123 + head. 121 124 122 125 Each display controller node has a child node, named "rgb", that represents 123 126 the RGB output associated with the controller. It can take the following
+39 -2
drivers/gpu/drm/tegra/dc.c
··· 1100 1100 struct tegra_dc *dc = host1x_client_to_dc(client); 1101 1101 int err; 1102 1102 1103 - dc->pipe = tegra->drm->mode_config.num_crtc; 1104 - 1105 1103 drm_crtc_init(tegra->drm, &dc->base, &tegra_crtc_funcs); 1106 1104 drm_mode_crtc_set_gamma_size(&dc->base, 256); 1107 1105 drm_crtc_helper_add(&dc->base, &tegra_crtc_helper_funcs); ··· 1185 1187 } 1186 1188 }; 1187 1189 1190 + static int tegra_dc_parse_dt(struct tegra_dc *dc) 1191 + { 1192 + struct device_node *np; 1193 + u32 value = 0; 1194 + int err; 1195 + 1196 + err = of_property_read_u32(dc->dev->of_node, "nvidia,head", &value); 1197 + if (err < 0) { 1198 + dev_err(dc->dev, "missing \"nvidia,head\" property\n"); 1199 + 1200 + /* 1201 + * If the nvidia,head property isn't present, try to find the 1202 + * correct head number by looking up the position of this 1203 + * display controller's node within the device tree. Assuming 1204 + * that the nodes are ordered properly in the DTS file and 1205 + * that the translation into a flattened device tree blob 1206 + * preserves that ordering this will actually yield the right 1207 + * head number. 1208 + * 1209 + * If those assumptions don't hold, this will still work for 1210 + * cases where only a single display controller is used. 1211 + */ 1212 + for_each_matching_node(np, tegra_dc_of_match) { 1213 + if (np == dc->dev->of_node) 1214 + break; 1215 + 1216 + value++; 1217 + } 1218 + } 1219 + 1220 + dc->pipe = value; 1221 + 1222 + return 0; 1223 + } 1224 + 1188 1225 static int tegra_dc_probe(struct platform_device *pdev) 1189 1226 { 1190 1227 const struct of_device_id *id; ··· 1239 1206 INIT_LIST_HEAD(&dc->list); 1240 1207 dc->dev = &pdev->dev; 1241 1208 dc->soc = id->data; 1209 + 1210 + err = tegra_dc_parse_dt(dc); 1211 + if (err < 0) 1212 + return err; 1242 1213 1243 1214 dc->clk = devm_clk_get(&pdev->dev, NULL); 1244 1215 if (IS_ERR(dc->clk)) {