summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Serbinenko <phcoder@gmail.com>2013-03-30 02:02:13 +0100
committerRonald G. Minnich <rminnich@gmail.com>2013-04-18 22:47:59 +0200
commit45988dab6bfbc480443979081a3260b7bce04fd8 (patch)
treef2b8fe77e984c3cfa6701c96ac9b645c42c449ed
parent8a6f7a77f3ab169480b8d22caf1a8d70e3188c62 (diff)
downloadcoreboot-45988dab6bfbc480443979081a3260b7bce04fd8.tar.xz
spkmodem console
Change-Id: Ie497e4c8da05001ffe67c4a541bd24aa859ac0e2 Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com> Reviewed-on: http://review.coreboot.org/2987 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
-rw-r--r--src/arch/x86/lib/romstage_console.c7
-rw-r--r--src/console/Kconfig6
-rw-r--r--src/console/Makefile.inc1
-rw-r--r--src/console/console.c4
-rw-r--r--src/console/spkmodem_console.c46
-rw-r--r--src/include/console/console.h3
-rw-r--r--src/include/console/spkmodem.h7
-rw-r--r--src/lib/Makefile.inc3
-rw-r--r--src/lib/spkmodem.c128
9 files changed, 205 insertions, 0 deletions
diff --git a/src/arch/x86/lib/romstage_console.c b/src/arch/x86/lib/romstage_console.c
index f53f5a9d75..2013bb7685 100644
--- a/src/arch/x86/lib/romstage_console.c
+++ b/src/arch/x86/lib/romstage_console.c
@@ -28,6 +28,10 @@
#if CONFIG_CONSOLE_NE2K
#include <console/ne2k.h>
#endif
+#if CONFIG_SPKMODEM
+#include <console/spkmodem.h>
+#endif
+
void console_tx_byte(unsigned char byte)
{
@@ -52,6 +56,9 @@ void console_tx_byte(unsigned char byte)
#if CONFIG_CONSOLE_CBMEM
cbmemc_tx_byte(byte);
#endif
+#if CONFIG_SPKMODEM
+ spkmodem_tx_byte(byte);
+#endif
}
void console_tx_flush(void)
diff --git a/src/console/Kconfig b/src/console/Kconfig
index d2cff572aa..6251589419 100644
--- a/src/console/Kconfig
+++ b/src/console/Kconfig
@@ -119,6 +119,12 @@ config TTYS0_LCS
default 3
depends on CONSOLE_SERIAL8250 || CONSOLE_SERIAL8250MEM
+config SPKMODEM
+ bool "spkmodem (console on speaker) console output"
+ default n
+ help
+ Send coreboot debug output through speaker
+
# Use "select HAVE_USBDEBUG" on southbridges which have Debug Port code.
config HAVE_USBDEBUG
def_bool n
diff --git a/src/console/Makefile.inc b/src/console/Makefile.inc
index 40bf357abf..15034cbabd 100644
--- a/src/console/Makefile.inc
+++ b/src/console/Makefile.inc
@@ -20,6 +20,7 @@ bootblock-y += die.c
ramstage-$(CONFIG_CONSOLE_SERIAL8250) += uart8250_console.c
ramstage-$(CONFIG_CONSOLE_SERIAL8250MEM) += uart8250mem_console.c
+ramstage-$(CONFIG_SPKMODEM) += spkmodem_console.c
ramstage-$(CONFIG_USBDEBUG) += usbdebug_console.c
ramstage-$(CONFIG_CONSOLE_LOGBUF) += logbuf_console.c
ramstage-$(CONFIG_CONSOLE_NE2K) += ne2k_console.c
diff --git a/src/console/console.c b/src/console/console.c
index afbba9dd4f..2f7de02655 100644
--- a/src/console/console.c
+++ b/src/console/console.c
@@ -119,6 +119,10 @@ void console_init(void)
#if CONFIG_CONSOLE_CBMEM
cbmemc_init();
#endif
+#if CONFIG_SPKMODEM
+ spkmodem_init();
+#endif
+
static const char console_test[] =
"\n\ncoreboot-"
COREBOOT_VERSION
diff --git a/src/console/spkmodem_console.c b/src/console/spkmodem_console.c
new file mode 100644
index 0000000000..814a1ac066
--- /dev/null
+++ b/src/console/spkmodem_console.c
@@ -0,0 +1,46 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2013 Vladimir Serbinenko
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <console/console.h>
+#include <console/spkmodem.h>
+
+static void spkmodem_tx_flush(void)
+{
+}
+
+static unsigned char spkmodem_rx_byte(void)
+{
+ return 0;
+}
+
+static int spkmodem_tst_byte(void)
+{
+ return 0;
+}
+
+
+static const struct console_driver spkmodem_console __console = {
+ .init = spkmodem_init,
+ .tx_byte = spkmodem_tx_byte,
+ .tx_flush = spkmodem_tx_flush,
+ .rx_byte = spkmodem_rx_byte,
+ .tst_byte = spkmodem_tst_byte,
+};
+
diff --git a/src/include/console/console.h b/src/include/console/console.h
index 0b636447be..d32009384d 100644
--- a/src/include/console/console.h
+++ b/src/include/console/console.h
@@ -36,6 +36,9 @@
#if CONFIG_CONSOLE_CBMEM
#include <console/cbmem_console.h>
#endif
+#if CONFIG_SPKMODEM
+#include <console/spkmodem.h>
+#endif
#ifndef __PRE_RAM__
unsigned char console_rx_byte(void);
diff --git a/src/include/console/spkmodem.h b/src/include/console/spkmodem.h
new file mode 100644
index 0000000000..450dbe8280
--- /dev/null
+++ b/src/include/console/spkmodem.h
@@ -0,0 +1,7 @@
+#ifndef SPKMODEM_H
+#define SPKMODEM_H 1
+
+void spkmodem_init(void);
+void spkmodem_tx_byte(unsigned char c);
+
+#endif
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index 9d3588ea60..e8b1485d81 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -47,6 +47,8 @@ romstage-$(CONFIG_CONSOLE_SERIAL8250MEM) += uart8250mem.c
romstage-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
romstage-$(CONFIG_CONSOLE_NE2K) += ne2k.c
romstage-$(CONFIG_USBDEBUG) += usbdebug.c
+romstage-$(CONFIG_SPKMODEM) += spkmodem.c
+
romstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
romstage-$(CONFIG_EARLY_CBMEM_INIT) += cbmem.c
romstage-y += compute_ip_checksum.c
@@ -81,6 +83,7 @@ ramstage-$(CONFIG_CONSOLE_SERIAL8250) += uart8250.c
ramstage-$(CONFIG_CONSOLE_SERIAL8250MEM) += uart8250mem.c
ramstage-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
ramstage-$(CONFIG_USBDEBUG) += usbdebug.c
+ramstage-$(CONFIG_SPKMODEM) += spkmodem.c
ramstage-$(CONFIG_BOOTSPLASH) += jpeg.c
ramstage-$(CONFIG_TRACE) += trace.c
ramstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
diff --git a/src/lib/spkmodem.c b/src/lib/spkmodem.c
new file mode 100644
index 0000000000..89773b158c
--- /dev/null
+++ b/src/lib/spkmodem.c
@@ -0,0 +1,128 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2013 Vladimir Serbinenko
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <console/console.h>
+#include <arch/io.h>
+#include <console/spkmodem.h>
+#include <cpu/x86/tsc.h>
+
+#define SPEAKER_PIT_FREQUENCY 0x1234dd
+
+
+enum {
+ PIT_COUNTER_0 = 0x40,
+ PIT_COUNTER_1 = 0x41,
+ PIT_COUNTER_2 = 0x42,
+ PIT_CTRL = 0x43,
+ PIT_SPEAKER_PORT = 0x61,
+};
+
+
+enum {
+ PIT_SPK_TMR2 = 0x01,
+ PIT_SPK_DATA = 0x02,
+ PIT_SPK_TMR2_LATCH = 0x20
+};
+
+enum {
+ PIT_CTRL_SELECT_MASK = 0xc0,
+ PIT_CTRL_SELECT_0 = 0x00,
+ PIT_CTRL_SELECT_1 = 0x40,
+ PIT_CTRL_SELECT_2 = 0x80,
+
+ PIT_CTRL_READLOAD_MASK= 0x30,
+ PIT_CTRL_COUNTER_LATCH = 0x00,
+ PIT_CTRL_READLOAD_LSB = 0x10,
+ PIT_CTRL_READLOAD_MSB = 0x20,
+ PIT_CTRL_READLOAD_WORD = 0x30,
+
+ PIT_CTRL_MODE_MASK = 0x0e,
+ PIT_CTRL_INTR_ON_TERM = 0x00,
+ PIT_CTRL_PROGR_ONE_SHOT = 0x02,
+
+ PIT_CTRL_RATE_GEN = 0x04,
+
+ PIT_CTRL_SQUAREWAVE_GEN = 0x06,
+ PIT_CTRL_SOFTSTROBE = 0x08,
+
+ PIT_CTRL_HARDSTROBE = 0x0a,
+
+
+ PIT_CTRL_COUNT_MASK = 0x01,
+ PIT_CTRL_COUNT_BINARY = 0x00,
+ PIT_CTRL_COUNT_BCD = 0x01
+};
+
+
+static void
+make_tone (uint16_t freq_count, unsigned int duration)
+{
+ outb (PIT_CTRL_SELECT_2
+ | PIT_CTRL_READLOAD_WORD
+ | PIT_CTRL_SQUAREWAVE_GEN
+ | PIT_CTRL_COUNT_BINARY, PIT_CTRL);
+
+ outb (freq_count & 0xff, PIT_COUNTER_2);
+
+ outb ((freq_count >> 8) & 0xff, PIT_COUNTER_2);
+
+ outb (inb (PIT_SPEAKER_PORT)
+ | PIT_SPK_TMR2 | PIT_SPK_DATA,
+ PIT_SPEAKER_PORT);
+
+ for (; duration; duration--) {
+ unsigned short counter, previous_counter = 0xffff;
+ while (1) {
+ counter = inb (PIT_COUNTER_2);
+ counter |= ((uint16_t) inb (PIT_COUNTER_2)) << 8;
+ if (counter > previous_counter)
+ {
+ previous_counter = counter;
+ break;
+ }
+ previous_counter = counter;
+ }
+ }
+}
+
+void spkmodem_tx_byte(unsigned char c)
+{
+ int i;
+
+ make_tone (SPEAKER_PIT_FREQUENCY / 200, 4);
+ for (i = 7; i >= 0; i--) {
+ if ((c >> i) & 1)
+ make_tone (SPEAKER_PIT_FREQUENCY / 2000, 20);
+ else
+ make_tone (SPEAKER_PIT_FREQUENCY / 4000, 40);
+ make_tone (SPEAKER_PIT_FREQUENCY / 1000, 10);
+ }
+ make_tone (SPEAKER_PIT_FREQUENCY / 200, 0);
+}
+
+void spkmodem_init(void)
+{
+ /* Some cards need time to come online. Output some message to get it started. */
+ spkmodem_tx_byte('S');
+ spkmodem_tx_byte('P');
+ spkmodem_tx_byte('K');
+ spkmodem_tx_byte('\r');
+ spkmodem_tx_byte('\n');
+}