1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2017 Microchip
4  *		      Wenyou Yang <wenyou.yang@microchip.com>
5  */
6 
7 #include <common.h>
8 #include <atmel_lcd.h>
9 #include <dm.h>
10 #include <init.h>
11 #include <nand.h>
12 #include <version.h>
13 #include <video.h>
14 #include <video_console.h>
15 #include <vsprintf.h>
16 #include <asm/global_data.h>
17 #include <asm/io.h>
18 #include <asm/arch/clk.h>
19 
20 DECLARE_GLOBAL_DATA_PTR;
21 
at91_video_show_board_info(void)22 int at91_video_show_board_info(void)
23 {
24 	struct vidconsole_priv *priv;
25 	ulong dram_size, nand_size;
26 	int i;
27 	u32 len = 0;
28 	char buf[255];
29 	char *corp = "Microchip Technology Inc.\n";
30 	char temp[32];
31 	struct udevice *dev, *con;
32 	const char *s;
33 	vidinfo_t logo_info;
34 	int ret;
35 
36 	len += sprintf(&buf[len], "%s\n", U_BOOT_VERSION);
37 	memcpy(&buf[len], corp, strlen(corp));
38 	len += strlen(corp);
39 	len += sprintf(&buf[len], "%s CPU at %s MHz\n", get_cpu_name(),
40 			strmhz(temp, get_cpu_clk_rate()));
41 
42 	dram_size = 0;
43 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++)
44 		dram_size += gd->bd->bi_dram[i].size;
45 
46 	nand_size = 0;
47 #ifdef CONFIG_NAND_ATMEL
48 	for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++)
49 		nand_size += get_nand_dev_by_index(i)->size;
50 #endif
51 
52 	len += sprintf(&buf[len], "%ld MB SDRAM, %ld MB NAND\n",
53 		       dram_size >> 20, nand_size >> 20);
54 
55 	ret = uclass_get_device(UCLASS_VIDEO, 0, &dev);
56 	if (ret)
57 		return ret;
58 
59 	microchip_logo_info(&logo_info);
60 	ret = video_bmp_display(dev, logo_info.logo_addr,
61 				logo_info.logo_x_offset,
62 				logo_info.logo_y_offset, false);
63 	if (ret)
64 		return ret;
65 
66 	ret = uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con);
67 	if (ret)
68 		return ret;
69 
70 	priv = dev_get_uclass_priv(con);
71 	vidconsole_position_cursor(con, 0, (logo_info.logo_height +
72 				   priv->y_charsize - 1) / priv->y_charsize);
73 	for (s = buf, i = 0; i < len; s++, i++)
74 		vidconsole_put_char(con, *s);
75 
76 	return 0;
77 }
78