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