From fe0ab650bbc30c41cd6da79749a15a76bf73bc3c Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 4 Jun 2019 16:35:56 -0600 Subject: [PATCH] configs/makerlisp: Add VGA initialization logic. --- configs/makerlisp/Kconfig | 7 +++ configs/makerlisp/README.txt | 15 +++--- configs/makerlisp/src/ez80_bringup.c | 5 +- configs/makerlisp/src/ez80_lowinit.c | 73 +++++++++++++++++++++++++++- 4 files changed, 90 insertions(+), 10 deletions(-) diff --git a/configs/makerlisp/Kconfig b/configs/makerlisp/Kconfig index 0b93d4bd01..c1fd169749 100644 --- a/configs/makerlisp/Kconfig +++ b/configs/makerlisp/Kconfig @@ -5,4 +5,11 @@ if ARCH_BOARD_MAKERLISP +config MAKERLISP_VGA + bool "VGA Controller attached?" + default n + ---help--- + Select this option if you have an I/O Controller and a VGA vide card + connected. + endif # ARCH_BOARD_MAKERLISP diff --git a/configs/makerlisp/README.txt b/configs/makerlisp/README.txt index 4f9bc5b9e8..ff11ef26f8 100644 --- a/configs/makerlisp/README.txt +++ b/configs/makerlisp/README.txt @@ -160,8 +160,9 @@ Serial Keyboard and VGA Display expansion board GPIO PB1. e. Transmit 'TX' pin on VGA board to USB keyboard controller 'R' - TBD: Beyond the simple UART interface, what additional support for the - ready pin 'C' is required. + To use the VGA display controller with stdout and stderr, you also + need to selection CONFIG_MAKERLISP_VGA=y in your configuration. This + enables a required VGA initialization sequence. 2. USB keyboard controller (UART0 RX) @@ -289,7 +290,9 @@ Configuration Subdirectories The default baud setting is 57600N1. - TBD: Although the UART0 is the same with the VGA and Keyboard - controller boards, this configuration may not compatible with - those accessories. Those may require additional support for - the VGA data ready pin. A BAUD mismatch is also likely. + To use the VGA display controller with stdout and stderr, you also + need to selection CONFIG_MAKERLISP_VGA=y in your configuration. This + enables a required VGA initialization sequence. + + TBD: What is the UART configuration when used with the VGA and + Keyboard controllers? diff --git a/configs/makerlisp/src/ez80_bringup.c b/configs/makerlisp/src/ez80_bringup.c index 9390bef025..311418b6a9 100644 --- a/configs/makerlisp/src/ez80_bringup.c +++ b/configs/makerlisp/src/ez80_bringup.c @@ -68,11 +68,10 @@ int ez80_bringup(void) #ifdef CONFIG_FS_PROCFS /* Mount the procfs file system */ - ret = mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL); + ret = mount(NULL, "/proc", "procfs", 0, NULL); if (ret < 0) { - serr("ERROR: Failed to mount procfs at %s: %d\n", - STM32_PROCFS_MOUNTPOINT, ret); + serr("ERROR: Failed to mount procfs at /proc: %d\n", ret); } #endif diff --git a/configs/makerlisp/src/ez80_lowinit.c b/configs/makerlisp/src/ez80_lowinit.c index f664c73fe5..63f1878905 100644 --- a/configs/makerlisp/src/ez80_lowinit.c +++ b/configs/makerlisp/src/ez80_lowinit.c @@ -4,7 +4,8 @@ * Copyright (C) 2019 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * - * Based upon sample code included with the Zilog ZDS-II toolchain. + * Parts of this file are based on MakerLisp sample code by Luther Johnson + * which has a compatible MIT license * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -47,6 +48,7 @@ #include #include "chip.h" +#include "up_internal.h" #include "makerlisp.h" /**************************************************************************** @@ -55,6 +57,66 @@ bool g_ebpresent = false; /* True: I/O Expansion board is present */ +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define VGA_MAX_DELAY 2000000 + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ez80_vga_initialize + * + * Description: + * If CONFIG_MAKERLISP_VGA is defined and the I/O controller is attached, + * then initialize the VGA interface. + * + ****************************************************************************/ + +#ifdef CONFIG_MAKERLISP_VGA +static void ez80_vga_initialize(void) +{ + /* I/O Expansion board attached? */ + + if (g_ebpresent) + { + bool vgapresent = false; + int delay; + + /* Wait for VGA ready */ + + for (delay = 0; delay < VGA_MAX_DELAY; delay++) + { + if *(inp(EZ80_PB_DR) & EZ80_GPIOD1) != 0) + { + vgapresent = true; + break; + } + } + + /* Is VGA ready (and, hence, present)? */ + + if (vgapresent) + { + /* Yes.. set newline mode, graphic attributes: + * + * \033 = ESCAPE character + * Assumption: VGA is on the console UART. + */ + + up_puts("\033[20h\033[0m"); + + /* Clear, home cursor, beep */ + + up_puts("\033[2J\033[H\a"); + } + } +} +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -136,6 +198,15 @@ void ez80_lowinit(void) /* Wait for the SD card to power up */ up_udelay(750); + +#ifdef CONFIG_MAKERLISP_VGA + /* Initialize the VGA interface. We want to do this as early as possible + * in the boot-up sequence. Debug output prior initializing VGA will be + * lost. + */ + + ez80_vga_initialize(); +#endif } /****************************************************************************