Svyatoslav Ryhel | 4a950b3 | 2023-11-03 21:00:22 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * (C) Copyright 2023 |
| 4 | * Svyatoslav Ryhel <clamor95@gmail.com> |
| 5 | */ |
| 6 | |
| 7 | #include <dm.h> |
| 8 | #include <dm/root.h> |
| 9 | #include <fdt_support.h> |
| 10 | #include <log.h> |
| 11 | #include <spl_gpio.h> |
| 12 | |
| 13 | static int star_fix_panel(void *fdt) |
| 14 | { |
| 15 | int panel_offset, ret; |
| 16 | |
| 17 | /* Patch panel compatible */ |
| 18 | spl_gpio_input(NULL, TEGRA_GPIO(J, 5)); |
| 19 | if (spl_gpio_get_value(NULL, TEGRA_GPIO(J, 5))) { |
| 20 | panel_offset = fdt_node_offset_by_compatible(fdt, -1, |
| 21 | "hit,tx10d07vm0baa"); |
| 22 | if (panel_offset < 0) { |
| 23 | log_debug("%s: panel node not found\n", __func__); |
| 24 | return panel_offset; |
| 25 | } |
| 26 | |
| 27 | ret = fdt_setprop_string(fdt, panel_offset, "compatible", |
| 28 | "lg,lh400wv3-sd04"); |
| 29 | if (ret) { |
| 30 | log_debug("%s: panel comapible patch failed\n", __func__); |
| 31 | return ret; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | return 0; |
| 36 | } |
| 37 | |
| 38 | void pinmux_init(void) |
| 39 | { |
| 40 | void *fdt = (void *)gd->fdt_blob; |
| 41 | |
| 42 | star_fix_panel(fdt); |
| 43 | } |
| 44 | |
| 45 | #if IS_ENABLED(CONFIG_OF_LIBFDT) && IS_ENABLED(CONFIG_OF_BOARD_SETUP) |
| 46 | int ft_board_setup(void *fdt, struct bd_info *bd) |
| 47 | { |
| 48 | return star_fix_panel(fdt); |
| 49 | } |
| 50 | #endif |