[coreboot-gerrit] New patch to review for coreboot: 7207305 spkmodem: Move under drivers/pc80

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Wed Feb 5 16:47:16 CET 2014


Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5134

-gerrit

commit 720730520bf512fd302b1a0f71c8be915d0d9880
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date:   Fri Jan 31 07:38:21 2014 +0200

    spkmodem: Move under drivers/pc80
    
    Change-Id: I46eb17ab19cea8759b3e4822019285cbe907e83a
    Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
 src/drivers/pc80/Makefile.inc |   5 +-
 src/drivers/pc80/spkmodem.c   | 128 ++++++++++++++++++++++++++++++++++++++++++
 src/lib/Makefile.inc          |   2 -
 src/lib/spkmodem.c            | 128 ------------------------------------------
 4 files changed, 132 insertions(+), 131 deletions(-)

diff --git a/src/drivers/pc80/Makefile.inc b/src/drivers/pc80/Makefile.inc
index 23e986a..4d0a280 100644
--- a/src/drivers/pc80/Makefile.inc
+++ b/src/drivers/pc80/Makefile.inc
@@ -4,9 +4,12 @@ ramstage-y += i8254.c
 ramstage-y += i8259.c
 ramstage-$(CONFIG_UDELAY_IO) += udelay_io.c
 ramstage-y += keyboard.c
-romstage-$(CONFIG_TPM) += tpm.c
+ramstage-$(CONFIG_SPKMODEM) += spkmodem.c
 
 romstage-$(CONFIG_USE_OPTION_TABLE) += mc146818rtc_early.c
+romstage-$(CONFIG_TPM) += tpm.c
+romstage-$(CONFIG_SPKMODEM) += spkmodem.c
+
 subdirs-y += vga
 
 cbfs-files-$(CONFIG_HAVE_CMOS_DEFAULT) += cmos.default
diff --git a/src/drivers/pc80/spkmodem.c b/src/drivers/pc80/spkmodem.c
new file mode 100644
index 0000000..89773b1
--- /dev/null
+++ b/src/drivers/pc80/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');
+}
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index b1b4748..3bad3fd 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -48,7 +48,6 @@ romstage-$(CONFIG_CACHE_AS_RAM) += ramtest.c
 romstage-$(CONFIG_CONSOLE_SERIAL8250) += uart8250.c
 romstage-$(CONFIG_CONSOLE_SERIAL8250MEM) += uart8250mem.c
 romstage-$(CONFIG_CONSOLE_NE2K) += ne2k.c
-romstage-$(CONFIG_SPKMODEM) += spkmodem.c
 
 ifeq ($(CONFIG_EARLY_CBMEM_INIT),y)
 romstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
@@ -91,7 +90,6 @@ romstage-y += clog2.c
 ramstage-$(CONFIG_CONSOLE_SERIAL8250) += uart8250.c
 ramstage-$(CONFIG_CONSOLE_SERIAL8250MEM) += uart8250mem.c
 ramstage-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.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
deleted file mode 100644
index 89773b1..0000000
--- a/src/lib/spkmodem.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * 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');
-}



More information about the coreboot-gerrit mailing list