blob: 9c0ec29c937b93fa166939bfd74761da485386c1 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Przemyslaw Marczak283a3202014-01-22 11:24:12 +01002/*
3 * Copyright (C) 2013 Samsung Electronics
4 * Przemyslaw Marczak <p.marczak@samsung.com>
Przemyslaw Marczak283a3202014-01-22 11:24:12 +01005 */
6
7#include <common.h>
Simon Glassadaaa482019-11-14 12:57:43 -07008#include <command.h>
Simon Glass5e6201b2019-08-01 09:46:51 -06009#include <env.h>
Przemyslaw Marczak283a3202014-01-22 11:24:12 +010010#include <libtizen.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060011#include <asm/global_data.h>
Simon Glassdbd79542020-05-10 11:40:11 -060012#include <linux/delay.h>
Przemyslaw Marczak283a3202014-01-22 11:24:12 +010013#include <samsung/misc.h>
Przemyslaw Marczaka8da5512014-01-22 11:24:17 +010014#include <errno.h>
15#include <version.h>
Przemyslaw Marczakfa9566f2014-09-01 13:50:46 +020016#include <malloc.h>
Simon Glass2dd337a2015-09-02 17:24:58 -060017#include <memalign.h>
Alexey Brodkin267d8e22014-02-26 17:47:58 +040018#include <linux/sizes.h>
Przemyslaw Marczaka8da5512014-01-22 11:24:17 +010019#include <asm/arch/cpu.h>
Przemyslaw Marczaka8da5512014-01-22 11:24:17 +010020#include <asm/gpio.h>
21#include <linux/input.h>
Przemyslaw Marczake7781bc2015-05-13 13:38:25 +020022#include <dm.h>
Simon Glass19eb1182017-05-18 20:09:31 -060023/*
24 * Use #ifdef to work around conflicting headers while we wait for this to be
25 * converted to driver model.
26 */
27#ifdef CONFIG_DM_PMIC_MAX77686
28#include <power/max77686_pmic.h>
29#endif
30#ifdef CONFIG_DM_PMIC_MAX8998
31#include <power/max8998_pmic.h>
32#endif
33#ifdef CONFIG_PMIC_MAX8997
34#include <power/max8997_pmic.h>
35#endif
Przemyslaw Marczaka8da5512014-01-22 11:24:17 +010036#include <power/pmic.h>
37#include <mmc.h>
38
39DECLARE_GLOBAL_DATA_PTR;
40
Przemyslaw Marczakfa9566f2014-09-01 13:50:46 +020041#ifdef CONFIG_SET_DFU_ALT_INFO
Przemyslaw Marczakd0dd6092015-02-17 12:24:11 +010042void set_dfu_alt_info(char *interface, char *devstr)
Przemyslaw Marczakfa9566f2014-09-01 13:50:46 +020043{
44 size_t buf_size = CONFIG_SET_DFU_ALT_BUF_LEN;
45 ALLOC_CACHE_ALIGN_BUFFER(char, buf, buf_size);
46 char *alt_info = "Settings not found!";
47 char *status = "error!\n";
48 char *alt_setting;
49 char *alt_sep;
50 int offset = 0;
51
52 puts("DFU alt info setting: ");
53
Przemyslaw Marczakd0dd6092015-02-17 12:24:11 +010054 alt_setting = get_dfu_alt_boot(interface, devstr);
Przemyslaw Marczakfa9566f2014-09-01 13:50:46 +020055 if (alt_setting) {
Simon Glass6a38e412017-08-03 12:22:09 -060056 env_set("dfu_alt_boot", alt_setting);
Przemyslaw Marczakfa9566f2014-09-01 13:50:46 +020057 offset = snprintf(buf, buf_size, "%s", alt_setting);
58 }
59
Przemyslaw Marczakd0dd6092015-02-17 12:24:11 +010060 alt_setting = get_dfu_alt_system(interface, devstr);
Przemyslaw Marczakfa9566f2014-09-01 13:50:46 +020061 if (alt_setting) {
62 if (offset)
63 alt_sep = ";";
64 else
65 alt_sep = "";
66
67 offset += snprintf(buf + offset, buf_size - offset,
68 "%s%s", alt_sep, alt_setting);
69 }
70
71 if (offset) {
72 alt_info = buf;
73 status = "done\n";
74 }
75
Simon Glass6a38e412017-08-03 12:22:09 -060076 env_set("dfu_alt_info", alt_info);
Przemyslaw Marczakfa9566f2014-09-01 13:50:46 +020077 puts(status);
78}
79#endif
80
Piotr Wilczek1b5c7662014-01-22 15:54:32 +010081#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
82void set_board_info(void)
83{
84 char info[64];
85
Przemyslaw Marczakb8b07242014-09-01 13:50:42 +020086 snprintf(info, ARRAY_SIZE(info), "%u.%u", (s5p_cpu_rev & 0xf0) >> 4,
87 s5p_cpu_rev & 0xf);
Simon Glass6a38e412017-08-03 12:22:09 -060088 env_set("soc_rev", info);
Piotr Wilczek1b5c7662014-01-22 15:54:32 +010089
90 snprintf(info, ARRAY_SIZE(info), "%x", s5p_cpu_id);
Simon Glass6a38e412017-08-03 12:22:09 -060091 env_set("soc_id", info);
Piotr Wilczek1b5c7662014-01-22 15:54:32 +010092
93#ifdef CONFIG_REVISION_TAG
94 snprintf(info, ARRAY_SIZE(info), "%x", get_board_rev());
Simon Glass6a38e412017-08-03 12:22:09 -060095 env_set("board_rev", info);
Piotr Wilczek1b5c7662014-01-22 15:54:32 +010096#endif
97#ifdef CONFIG_OF_LIBFDT
Przemyslaw Marczak2cadc4d2014-09-01 13:50:50 +020098 const char *bdtype = "";
99 const char *bdname = CONFIG_SYS_BOARD;
100
101#ifdef CONFIG_BOARD_TYPES
102 bdtype = get_board_type();
Przemyslaw Marczak5b8bbbf2015-10-27 13:07:54 +0100103 if (!bdtype)
104 bdtype = "";
105
Przemyslaw Marczak2cadc4d2014-09-01 13:50:50 +0200106 sprintf(info, "%s%s", bdname, bdtype);
Krzysztof Kozlowskif4befd42019-02-22 19:36:43 +0100107 env_set("board_name", info);
Przemyslaw Marczak2cadc4d2014-09-01 13:50:50 +0200108#endif
109 snprintf(info, ARRAY_SIZE(info), "%s%x-%s%s.dtb",
110 CONFIG_SYS_SOC, s5p_cpu_id, bdname, bdtype);
Simon Glass6a38e412017-08-03 12:22:09 -0600111 env_set("fdtfile", info);
Piotr Wilczek1b5c7662014-01-22 15:54:32 +0100112#endif
113}
114#endif /* CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG */
115
Przemyslaw Marczak283a3202014-01-22 11:24:12 +0100116#ifdef CONFIG_CMD_BMP
117void draw_logo(void)
118{
119 int x, y;
120 ulong addr;
121
122 addr = panel_info.logo_addr;
123 if (!addr) {
Seung-Woo Kimca211662018-06-04 16:03:05 +0900124 pr_err("There is no logo data.\n");
Przemyslaw Marczak283a3202014-01-22 11:24:12 +0100125 return;
126 }
127
128 if (panel_info.vl_width >= panel_info.logo_width) {
129 x = ((panel_info.vl_width - panel_info.logo_width) >> 1);
Przemyslaw Marczak02f4a092013-11-29 18:30:43 +0100130 x += panel_info.logo_x_offset; /* For X center align */
Przemyslaw Marczak283a3202014-01-22 11:24:12 +0100131 } else {
132 x = 0;
133 printf("Warning: image width is bigger than display width\n");
134 }
135
136 if (panel_info.vl_height >= panel_info.logo_height) {
137 y = ((panel_info.vl_height - panel_info.logo_height) >> 1);
Przemyslaw Marczak02f4a092013-11-29 18:30:43 +0100138 y += panel_info.logo_y_offset; /* For Y center align */
Przemyslaw Marczak283a3202014-01-22 11:24:12 +0100139 } else {
140 y = 0;
141 printf("Warning: image height is bigger than display height\n");
142 }
143
144 bmp_display(addr, x, y);
145}
146#endif /* CONFIG_CMD_BMP */