Add new Kconfig option to enable/disable beeps during LinuxBIOS boot.

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>



git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@274 f3766cd6-281f-0410-b1cd-43a5c92072e9
This commit is contained in:
Uwe Hermann 2007-04-06 12:04:28 +00:00
commit afa7c1d798
5 changed files with 128 additions and 2 deletions

View file

@ -30,6 +30,13 @@ config LOCALVERSION
help
Append an extra string to the end of the LinuxBIOS version.
config BEEPS
bool "Enable beeps upon certain LinuxBIOS events."
depends EXPERT
default n
help
Enable this option to make LinuxBIOS beep upon certain events.
endmenu
source mainboard/Kconfig

View file

@ -62,8 +62,8 @@ $(obj)/linuxbios.bootblock: $(obj)/linuxbios.vpd $(obj)/stage0.init
#
STAGE0_CONSOLE_OBJ = vtxprintf.o vsprintf.o console.o
STAGE0_LIB_OBJ = uart8250.o mem.o elfboot.o lar.o
STAGE0_ARCH_X86_OBJ = cachemain.o serial.o archelfboot.o
STAGE0_LIB_OBJ = uart8250.o mem.o elfboot.o lar.o delay.o
STAGE0_ARCH_X86_OBJ = cachemain.o serial.o archelfboot.o speaker.o udelay_io.o
ifeq ($(CONFIG_CAR_TYPE_I586),y)
STAGE0_CAR_OBJ = stage0_i586.o

View file

@ -22,6 +22,7 @@
#include <console/console.h>
#include <lar.h>
#include <linuxbios_tables.h>
#include <lib.h>
/* these prototypes should go into headers */
void uart_init(void);
@ -47,7 +48,9 @@ static void stop_ap(void)
static void enable_superio(void)
{
// nothing yet
beep_short(); // FIXME
post_code(0xf1);
beep_long(); // FIXME
}
static void enable_rom(void)

113
arch/x86/speaker.c Normal file
View file

@ -0,0 +1,113 @@
/*
* This file is part of the LinuxBIOS project.
*
* Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.de>
*
* 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
*/
/*
* Datasheet:
* - Name: 82C54 CHMOS Programmable Interval Timer
* - PDF: http://www.intel.com/design/archives/periphrl/docs/23124406.pdf
* - Order number: 231244-006
*/
#include <arch/io.h>
#include <lib.h>
#define I82C54_CONTROL_WORD_REGISTER 0x43 /* Write-only. */
#define I82C54_COUNTER0 0x40
#define I82C54_COUNTER1 0x41
#define I82C54_COUNTER2 0x42
#define PC_SPEAKER_PORT 0x61
/**
* Use the PC speaker to create a tone/sound of the specified frequency.
*
* The Intel 82C54 CHMOS Programmable Interval Timer (PIT) provides a
* superset of the functions of the original Intel 8253/8254 PIT. It has
* three programmable counters/timers (counter 0, 1, and 2). Counter 2 can
* be used to generate tones/sounds of various frequencies and duration.
*
* See also:
* - http://en.wikipedia.org/wiki/Pc_speaker
* - http://en.wikipedia.org/wiki/Intel_8253
*
* @param The frequency of the tone.
*/
void speaker_enable(u16 freq)
{
/* Select counter 2. Read/write LSB first, then MSB. Use mode 3
(square wave generator). Use a 16bit binary counter. */
outb(0xb6, I82C54_CONTROL_WORD_REGISTER);
/* Set the desired tone frequency. */
outb((u8)(freq & 0x00ff), I82C54_COUNTER2); /* LSB. */
outb((u8)(freq >> 8), I82C54_COUNTER2); /* MSB. */
/* Enable the PC speaker (set bits 0 and 1). */
outb(inb(PC_SPEAKER_PORT) | 0x03, PC_SPEAKER_PORT);
}
/**
* Disable the PC speaker.
*/
void speaker_disable(void)
{
/* Disable the PC speaker (clear bits 0 and 1). */
outb(inb(PC_SPEAKER_PORT) & 0xfc, PC_SPEAKER_PORT);
}
/**
* Use the PC speaker to create a tone/beep of the specified frequency
* and duration.
*
* Wait for a short amount of time after the beep to make it distinguishable
* from the next beep (if any).
*
* @param The frequency of the tone/beep.
* @param The duration of the tone/beep in milliseconds.
*/
void speaker_tone(u16 freq, unsigned int duration)
{
speaker_enable(freq);
mdelay(duration);
speaker_disable();
delay(10);
}
/**
* Use the PC speaker to create a short tone/beep.
*/
void beep_short(void)
{
#if defined(CONFIG_BEEPS) && (CONFIG_BEEPS == 1)
speaker_tone(1760, 500); /* 1760 == note A6. */
#endif
}
/**
* Use the PC speaker to create a long tone/beep.
*/
void beep_long(void)
{
#if defined(CONFIG_BEEPS) && (CONFIG_BEEPS == 1)
speaker_tone(1760, 2000); /* 1760 == note A6. */
#endif
}

View file

@ -27,4 +27,7 @@ void udelay(unsigned int usecs);
void mdelay(unsigned int msecs);
void delay(unsigned int secs);
void beep_short(void);
void beep_long(void);
#endif