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