Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Przemyslaw Marczak | 283a320 | 2014-01-22 11:24:12 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2013 Samsung Electronics |
| 4 | * Przemyslaw Marczak <p.marczak@samsung.com> |
Przemyslaw Marczak | 283a320 | 2014-01-22 11:24:12 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
Tom Rini | dec7ea0 | 2024-05-20 13:35:03 -0600 | [diff] [blame] | 7 | #include <config.h> |
Simon Glass | adaaa48 | 2019-11-14 12:57:43 -0700 | [diff] [blame] | 8 | #include <command.h> |
Simon Glass | 5e6201b | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 9 | #include <env.h> |
Przemyslaw Marczak | 283a320 | 2014-01-22 11:24:12 +0100 | [diff] [blame] | 10 | #include <libtizen.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 11 | #include <asm/global_data.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 12 | #include <linux/delay.h> |
Simon Glass | bdd5f81 | 2023-09-14 18:21:46 -0600 | [diff] [blame] | 13 | #include <linux/printk.h> |
Przemyslaw Marczak | 283a320 | 2014-01-22 11:24:12 +0100 | [diff] [blame] | 14 | #include <samsung/misc.h> |
Przemyslaw Marczak | a8da551 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 15 | #include <errno.h> |
| 16 | #include <version.h> |
Przemyslaw Marczak | fa9566f | 2014-09-01 13:50:46 +0200 | [diff] [blame] | 17 | #include <malloc.h> |
Simon Glass | 2dd337a | 2015-09-02 17:24:58 -0600 | [diff] [blame] | 18 | #include <memalign.h> |
Alexey Brodkin | 267d8e2 | 2014-02-26 17:47:58 +0400 | [diff] [blame] | 19 | #include <linux/sizes.h> |
Przemyslaw Marczak | a8da551 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 20 | #include <asm/arch/cpu.h> |
Przemyslaw Marczak | a8da551 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 21 | #include <asm/gpio.h> |
| 22 | #include <linux/input.h> |
Przemyslaw Marczak | e7781bc | 2015-05-13 13:38:25 +0200 | [diff] [blame] | 23 | #include <dm.h> |
Simon Glass | 19eb118 | 2017-05-18 20:09:31 -0600 | [diff] [blame] | 24 | /* |
| 25 | * Use #ifdef to work around conflicting headers while we wait for this to be |
| 26 | * converted to driver model. |
| 27 | */ |
| 28 | #ifdef CONFIG_DM_PMIC_MAX77686 |
| 29 | #include <power/max77686_pmic.h> |
| 30 | #endif |
| 31 | #ifdef CONFIG_DM_PMIC_MAX8998 |
| 32 | #include <power/max8998_pmic.h> |
| 33 | #endif |
| 34 | #ifdef CONFIG_PMIC_MAX8997 |
| 35 | #include <power/max8997_pmic.h> |
| 36 | #endif |
Przemyslaw Marczak | a8da551 | 2014-01-22 11:24:17 +0100 | [diff] [blame] | 37 | #include <power/pmic.h> |
| 38 | #include <mmc.h> |
| 39 | |
| 40 | DECLARE_GLOBAL_DATA_PTR; |
| 41 | |
Przemyslaw Marczak | fa9566f | 2014-09-01 13:50:46 +0200 | [diff] [blame] | 42 | #ifdef CONFIG_SET_DFU_ALT_INFO |
Przemyslaw Marczak | d0dd609 | 2015-02-17 12:24:11 +0100 | [diff] [blame] | 43 | void set_dfu_alt_info(char *interface, char *devstr) |
Przemyslaw Marczak | fa9566f | 2014-09-01 13:50:46 +0200 | [diff] [blame] | 44 | { |
Tom Rini | cee139a | 2022-12-04 10:13:46 -0500 | [diff] [blame] | 45 | size_t buf_size = CFG_SET_DFU_ALT_BUF_LEN; |
Przemyslaw Marczak | fa9566f | 2014-09-01 13:50:46 +0200 | [diff] [blame] | 46 | ALLOC_CACHE_ALIGN_BUFFER(char, buf, buf_size); |
| 47 | char *alt_info = "Settings not found!"; |
| 48 | char *status = "error!\n"; |
| 49 | char *alt_setting; |
| 50 | char *alt_sep; |
| 51 | int offset = 0; |
| 52 | |
| 53 | puts("DFU alt info setting: "); |
| 54 | |
Przemyslaw Marczak | d0dd609 | 2015-02-17 12:24:11 +0100 | [diff] [blame] | 55 | alt_setting = get_dfu_alt_boot(interface, devstr); |
Przemyslaw Marczak | fa9566f | 2014-09-01 13:50:46 +0200 | [diff] [blame] | 56 | if (alt_setting) { |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 57 | env_set("dfu_alt_boot", alt_setting); |
Przemyslaw Marczak | fa9566f | 2014-09-01 13:50:46 +0200 | [diff] [blame] | 58 | offset = snprintf(buf, buf_size, "%s", alt_setting); |
| 59 | } |
| 60 | |
Przemyslaw Marczak | d0dd609 | 2015-02-17 12:24:11 +0100 | [diff] [blame] | 61 | alt_setting = get_dfu_alt_system(interface, devstr); |
Przemyslaw Marczak | fa9566f | 2014-09-01 13:50:46 +0200 | [diff] [blame] | 62 | if (alt_setting) { |
| 63 | if (offset) |
| 64 | alt_sep = ";"; |
| 65 | else |
| 66 | alt_sep = ""; |
| 67 | |
| 68 | offset += snprintf(buf + offset, buf_size - offset, |
| 69 | "%s%s", alt_sep, alt_setting); |
| 70 | } |
| 71 | |
| 72 | if (offset) { |
| 73 | alt_info = buf; |
| 74 | status = "done\n"; |
| 75 | } |
| 76 | |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 77 | env_set("dfu_alt_info", alt_info); |
Przemyslaw Marczak | fa9566f | 2014-09-01 13:50:46 +0200 | [diff] [blame] | 78 | puts(status); |
| 79 | } |
| 80 | #endif |
| 81 | |
Piotr Wilczek | 1b5c766 | 2014-01-22 15:54:32 +0100 | [diff] [blame] | 82 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
| 83 | void set_board_info(void) |
| 84 | { |
| 85 | char info[64]; |
| 86 | |
Przemyslaw Marczak | b8b0724 | 2014-09-01 13:50:42 +0200 | [diff] [blame] | 87 | snprintf(info, ARRAY_SIZE(info), "%u.%u", (s5p_cpu_rev & 0xf0) >> 4, |
| 88 | s5p_cpu_rev & 0xf); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 89 | env_set("soc_rev", info); |
Piotr Wilczek | 1b5c766 | 2014-01-22 15:54:32 +0100 | [diff] [blame] | 90 | |
| 91 | snprintf(info, ARRAY_SIZE(info), "%x", s5p_cpu_id); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 92 | env_set("soc_id", info); |
Piotr Wilczek | 1b5c766 | 2014-01-22 15:54:32 +0100 | [diff] [blame] | 93 | |
| 94 | #ifdef CONFIG_REVISION_TAG |
| 95 | snprintf(info, ARRAY_SIZE(info), "%x", get_board_rev()); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 96 | env_set("board_rev", info); |
Piotr Wilczek | 1b5c766 | 2014-01-22 15:54:32 +0100 | [diff] [blame] | 97 | #endif |
| 98 | #ifdef CONFIG_OF_LIBFDT |
Przemyslaw Marczak | 2cadc4d | 2014-09-01 13:50:50 +0200 | [diff] [blame] | 99 | const char *bdtype = ""; |
| 100 | const char *bdname = CONFIG_SYS_BOARD; |
| 101 | |
| 102 | #ifdef CONFIG_BOARD_TYPES |
| 103 | bdtype = get_board_type(); |
Przemyslaw Marczak | 5b8bbbf | 2015-10-27 13:07:54 +0100 | [diff] [blame] | 104 | if (!bdtype) |
| 105 | bdtype = ""; |
| 106 | |
Przemyslaw Marczak | 2cadc4d | 2014-09-01 13:50:50 +0200 | [diff] [blame] | 107 | sprintf(info, "%s%s", bdname, bdtype); |
Krzysztof Kozlowski | f4befd4 | 2019-02-22 19:36:43 +0100 | [diff] [blame] | 108 | env_set("board_name", info); |
Przemyslaw Marczak | 2cadc4d | 2014-09-01 13:50:50 +0200 | [diff] [blame] | 109 | #endif |
| 110 | snprintf(info, ARRAY_SIZE(info), "%s%x-%s%s.dtb", |
| 111 | CONFIG_SYS_SOC, s5p_cpu_id, bdname, bdtype); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 112 | env_set("fdtfile", info); |
Piotr Wilczek | 1b5c766 | 2014-01-22 15:54:32 +0100 | [diff] [blame] | 113 | #endif |
| 114 | } |
| 115 | #endif /* CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG */ |
| 116 | |
Przemyslaw Marczak | 283a320 | 2014-01-22 11:24:12 +0100 | [diff] [blame] | 117 | #ifdef CONFIG_CMD_BMP |
| 118 | void draw_logo(void) |
| 119 | { |
| 120 | int x, y; |
| 121 | ulong addr; |
| 122 | |
| 123 | addr = panel_info.logo_addr; |
| 124 | if (!addr) { |
Seung-Woo Kim | ca21166 | 2018-06-04 16:03:05 +0900 | [diff] [blame] | 125 | pr_err("There is no logo data.\n"); |
Przemyslaw Marczak | 283a320 | 2014-01-22 11:24:12 +0100 | [diff] [blame] | 126 | return; |
| 127 | } |
| 128 | |
| 129 | if (panel_info.vl_width >= panel_info.logo_width) { |
| 130 | x = ((panel_info.vl_width - panel_info.logo_width) >> 1); |
Przemyslaw Marczak | 02f4a09 | 2013-11-29 18:30:43 +0100 | [diff] [blame] | 131 | x += panel_info.logo_x_offset; /* For X center align */ |
Przemyslaw Marczak | 283a320 | 2014-01-22 11:24:12 +0100 | [diff] [blame] | 132 | } else { |
| 133 | x = 0; |
| 134 | printf("Warning: image width is bigger than display width\n"); |
| 135 | } |
| 136 | |
| 137 | if (panel_info.vl_height >= panel_info.logo_height) { |
| 138 | y = ((panel_info.vl_height - panel_info.logo_height) >> 1); |
Przemyslaw Marczak | 02f4a09 | 2013-11-29 18:30:43 +0100 | [diff] [blame] | 139 | y += panel_info.logo_y_offset; /* For Y center align */ |
Przemyslaw Marczak | 283a320 | 2014-01-22 11:24:12 +0100 | [diff] [blame] | 140 | } else { |
| 141 | y = 0; |
| 142 | printf("Warning: image height is bigger than display height\n"); |
| 143 | } |
| 144 | |
| 145 | bmp_display(addr, x, y); |
| 146 | } |
| 147 | #endif /* CONFIG_CMD_BMP */ |