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 <nand.h>
11 #include <version.h>
12 #include <video.h>
13 #include <video_console.h>
14 #include <asm/io.h>
15 #include <asm/arch/clk.h>
16 
17 DECLARE_GLOBAL_DATA_PTR;
18 
19 int at91_video_show_board_info(void)
20 {
21 	ulong dram_size, nand_size;
22 	int i;
23 	u32 len = 0;
24 	char buf[255];
25 	char *corp = "2017 Microchip Technology Inc.\n";
26 	char temp[32];
27 	struct udevice *dev, *con;
28 	const char *s;
29 	vidinfo_t logo_info;
30 	int ret;
31 
32 	len += sprintf(&buf[len], "%s\n", U_BOOT_VERSION);
33 	memcpy(&buf[len], corp, strlen(corp));
34 	len += strlen(corp);
35 	len += sprintf(&buf[len], "%s CPU at %s MHz\n", get_cpu_name(),
36 			strmhz(temp, get_cpu_clk_rate()));
37 
38 	dram_size = 0;
39 	for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++)
40 		dram_size += gd->bd->bi_dram[i].size;
41 
42 	nand_size = 0;
43 #ifdef CONFIG_NAND_ATMEL
44 	for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++)
45 		nand_size += get_nand_dev_by_index(i)->size;
46 #endif
47 
48 	len += sprintf(&buf[len], "%ld MB SDRAM, %ld MB NAND\n",
49 		       dram_size >> 20, nand_size >> 20);
50 
51 	ret = uclass_get_device(UCLASS_VIDEO, 0, &dev);
52 	if (ret)
53 		return ret;
54 
55 	microchip_logo_info(&logo_info);
56 	ret = video_bmp_display(dev, logo_info.logo_addr,
57 				logo_info.logo_x_offset,
58 				logo_info.logo_y_offset, false);
59 	if (ret)
60 		return ret;
61 
62 	ret = uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con);
63 	if (ret)
64 		return ret;
65 
66 	vidconsole_position_cursor(con, 0, logo_info.logo_height);
67 	for (s = buf, i = 0; i < len; s++, i++)
68 		vidconsole_put_char(con, *s);
69 
70 	return 0;
71 }
72