summaryrefslogtreecommitdiffstats
path: root/src/usr/console
diff options
context:
space:
mode:
authorPatrick Williams <iawillia@us.ibm.com>2014-09-09 10:21:21 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2014-09-24 16:15:11 -0500
commit22b01c7d2dc49f788a7677f6415e67c054caaf99 (patch)
treed6a613f443cf3f135a3b999d53959d5ffbce2422 /src/usr/console
parent35cdaf24fa1b3f4fd4816726d45c750212b83daf (diff)
downloadtalos-hostboot-22b01c7d2dc49f788a7677f6415e67c054caaf99.tar.gz
talos-hostboot-22b01c7d2dc49f788a7677f6415e67c054caaf99.zip
Support AST2400 Console.
Change-Id: Iaf2da65e0a965001c7387b86daa2990934e7dbb9 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/13251 Tested-by: Jenkins Server Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/console')
-rw-r--r--src/usr/console/HBconfig6
-rw-r--r--src/usr/console/ast2400.C124
-rw-r--r--src/usr/console/console.C3
-rw-r--r--src/usr/console/makefile2
4 files changed, 135 insertions, 0 deletions
diff --git a/src/usr/console/HBconfig b/src/usr/console/HBconfig
index ee8885cbf..4f667522d 100644
--- a/src/usr/console/HBconfig
+++ b/src/usr/console/HBconfig
@@ -2,3 +2,9 @@ config CONSOLE
default n
help
Enable console support.
+
+config CONSOLE_AST2400
+ default y if CONSOLE
+ depends on CONSOLE
+ help
+ Console support for AST2400 device.
diff --git a/src/usr/console/ast2400.C b/src/usr/console/ast2400.C
new file mode 100644
index 000000000..0723c5342
--- /dev/null
+++ b/src/usr/console/ast2400.C
@@ -0,0 +1,124 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/console/ast2400.C $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2014 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+#include "uart.H"
+#include <devicefw/userif.H>
+#include <lpc/lpcif.H>
+#include <errl/errlmanager.H>
+
+namespace CONSOLE
+{
+
+/** Overload the base class with Ast2400 specifices.
+ *
+ * In initialization we need to program the SIO device on the AST2400 to
+ * enable the Uart device.
+ */
+class Ast2400Uart : public Uart
+{
+ private:
+
+ // Perform raw LPC writes to SIO region.
+ errlHndl_t _writeReg(uint64_t i_addr, uint8_t i_byte)
+ {
+ size_t len = sizeof(i_byte);
+ return deviceWrite(TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL,
+ &i_byte,
+ len,
+ DEVICE_LPC_ADDRESS(LPC::TRANS_IO, i_addr));
+ }
+
+ public:
+
+ virtual void initialize()
+ {
+ errlHndl_t l_errl = NULL;
+
+ do
+ {
+
+ // Unlock the SIO registers
+ // (write 0xA5 password to offset 0x2E two times)
+ l_errl = _writeReg( 0x2e, 0xA5 );
+ if (l_errl) { break; }
+ l_errl = _writeReg( 0x2e, 0xA5 );
+ if (l_errl) { break; }
+
+ // Select logical device 2 (SUART1) in SIO
+ l_errl = _writeReg( 0x2e, 0x07 ); // select logical dev number
+ if (l_errl) { break; }
+ l_errl = _writeReg( 0x2f, 0x02 ); // write device 2
+ if (l_errl) { break; }
+
+ // Disable SUART1 to change settings
+ l_errl = _writeReg( 0x2e, 0x30 ); // select SIO base enable
+ if (l_errl) { break; }
+ l_errl = _writeReg( 0x2f, 0x00 ); // clear enable
+ if (l_errl) { break; }
+
+ // Set SUART1 addr to g_uartBase
+ l_errl = _writeReg( 0x2e, 0x60 ); // select SIO addr[7:3]
+ if (l_errl) { break; }
+ l_errl = _writeReg( 0x2f, (g_uartBase >> 8) & 0xFF );
+ if (l_errl) { break; }
+ l_errl = _writeReg( 0x2e, 0x61 ); // select SIO addr[15:8]
+ if (l_errl) { break; }
+ l_errl = _writeReg( 0x2f, (g_uartBase & 0xFF) );
+ if (l_errl) { break; }
+
+ // Set the SerIRQ
+ l_errl = _writeReg( 0x2e, 0x70 );
+ if (l_errl) { break; }
+ l_errl = _writeReg( 0x2f, 0x04 );
+ if (l_errl) { break; }
+ l_errl = _writeReg( 0x2e, 0x71 );
+ if (l_errl) { break; }
+ l_errl = _writeReg( 0x2f, 0x01 );
+
+ // Enable SUART1
+ l_errl = _writeReg( 0x2e, 0x30 ); // select SIO base enable
+ if (l_errl) { break; }
+ l_errl = _writeReg( 0x2f, 0x01 ); // write enable
+ if (l_errl) { break; }
+
+ // Lock the SIO registers
+ l_errl = _writeReg( 0x2e, 0xAA );
+ if (l_errl) { break; }
+
+ } while(0);
+
+ if (l_errl)
+ {
+ setFailed();
+ errlCommit(l_errl, CONSOLE_COMP_ID);
+ }
+
+ Uart::initialize();
+ }
+
+};
+
+CONSOLE_UART_DEFINE_DEVICE(Ast2400Uart);
+
+}
diff --git a/src/usr/console/console.C b/src/usr/console/console.C
index 74f496f93..8a066fe85 100644
--- a/src/usr/console/console.C
+++ b/src/usr/console/console.C
@@ -6,6 +6,7 @@
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2014 */
+/* [+] Google Inc. */
/* [+] International Business Machines Corp. */
/* [+] Google Inc. */
/* */
@@ -66,6 +67,8 @@ namespace CONSOLE
class OutputBuffer : public Util::ConsoleBufferInterface
{
public:
+ OutputBuffer() { str.reserve(64); }
+
int putc(int c)
{
str.push_back(c);
diff --git a/src/usr/console/makefile b/src/usr/console/makefile
index 8252fb17a..2ff59d71d 100644
--- a/src/usr/console/makefile
+++ b/src/usr/console/makefile
@@ -8,6 +8,7 @@
# Contributors Listed Below - COPYRIGHT 2014
# [+] Google Inc.
# [+] International Business Machines Corp.
+# [+] Google Inc.
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -29,5 +30,6 @@ MODULE = console
OBJS += daemon.o
OBJS += uart.o
OBJS += uartconfig.o
+OBJS += $(if $(CONFIG_CONSOLE_AST2400),ast2400.o)
include $(ROOTPATH)/config.mk
OpenPOWER on IntegriCloud