Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Wenyou Yang | 7879f96 | 2017-09-13 14:58:47 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2017 Microchip |
| 4 | * Wenyou Yang <wenyou.yang@microchip.com> |
Wenyou Yang | 7879f96 | 2017-09-13 14:58:47 +0800 | [diff] [blame] | 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> |
Simon Glass | f5c208d | 2019-11-14 12:57:20 -0700 | [diff] [blame] | 14 | #include <vsprintf.h> |
Wenyou Yang | 7879f96 | 2017-09-13 14:58:47 +0800 | [diff] [blame] | 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 | { |
Simon Glass | 59f4421 | 2018-10-01 12:22:47 -0600 | [diff] [blame] | 22 | struct vidconsole_priv *priv; |
Wenyou Yang | 7879f96 | 2017-09-13 14:58:47 +0800 | [diff] [blame] | 23 | ulong dram_size, nand_size; |
| 24 | int i; |
| 25 | u32 len = 0; |
| 26 | char buf[255]; |
Eugen Hristev | 3ef9172 | 2019-08-28 08:34:03 +0000 | [diff] [blame] | 27 | char *corp = "Microchip Technology Inc.\n"; |
Wenyou Yang | 7879f96 | 2017-09-13 14:58:47 +0800 | [diff] [blame] | 28 | char temp[32]; |
| 29 | struct udevice *dev, *con; |
| 30 | const char *s; |
| 31 | vidinfo_t logo_info; |
| 32 | int ret; |
| 33 | |
| 34 | len += sprintf(&buf[len], "%s\n", U_BOOT_VERSION); |
| 35 | memcpy(&buf[len], corp, strlen(corp)); |
| 36 | len += strlen(corp); |
| 37 | len += sprintf(&buf[len], "%s CPU at %s MHz\n", get_cpu_name(), |
| 38 | strmhz(temp, get_cpu_clk_rate())); |
| 39 | |
| 40 | dram_size = 0; |
| 41 | for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) |
| 42 | dram_size += gd->bd->bi_dram[i].size; |
| 43 | |
| 44 | nand_size = 0; |
| 45 | #ifdef CONFIG_NAND_ATMEL |
| 46 | for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) |
Wenyou Yang | 426691e | 2017-09-18 15:26:00 +0800 | [diff] [blame] | 47 | nand_size += get_nand_dev_by_index(i)->size; |
Wenyou Yang | 7879f96 | 2017-09-13 14:58:47 +0800 | [diff] [blame] | 48 | #endif |
| 49 | |
| 50 | len += sprintf(&buf[len], "%ld MB SDRAM, %ld MB NAND\n", |
| 51 | dram_size >> 20, nand_size >> 20); |
| 52 | |
| 53 | ret = uclass_get_device(UCLASS_VIDEO, 0, &dev); |
| 54 | if (ret) |
| 55 | return ret; |
| 56 | |
| 57 | microchip_logo_info(&logo_info); |
| 58 | ret = video_bmp_display(dev, logo_info.logo_addr, |
| 59 | logo_info.logo_x_offset, |
| 60 | logo_info.logo_y_offset, false); |
| 61 | if (ret) |
| 62 | return ret; |
| 63 | |
| 64 | ret = uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con); |
| 65 | if (ret) |
| 66 | return ret; |
| 67 | |
Simon Glass | 59f4421 | 2018-10-01 12:22:47 -0600 | [diff] [blame] | 68 | priv = dev_get_uclass_priv(con); |
| 69 | vidconsole_position_cursor(con, 0, (logo_info.logo_height + |
| 70 | priv->y_charsize - 1) / priv->y_charsize); |
Wenyou Yang | 7879f96 | 2017-09-13 14:58:47 +0800 | [diff] [blame] | 71 | for (s = buf, i = 0; i < len; s++, i++) |
| 72 | vidconsole_put_char(con, *s); |
| 73 | |
| 74 | return 0; |
| 75 | } |