summaryrefslogtreecommitdiff
path: root/src/pc80
diff options
context:
space:
mode:
Diffstat (limited to 'src/pc80')
-rw-r--r--src/pc80/Makefile.inc2
-rw-r--r--src/pc80/mc146818rtc.c36
-rw-r--r--src/pc80/mc146818rtc_early.c31
-rw-r--r--src/pc80/serial.c5
4 files changed, 12 insertions, 62 deletions
diff --git a/src/pc80/Makefile.inc b/src/pc80/Makefile.inc
index 5ed40b3802..b20f2b4161 100644
--- a/src/pc80/Makefile.inc
+++ b/src/pc80/Makefile.inc
@@ -3,7 +3,7 @@ obj-y += isa-dma.o
obj-y += i8259.o
obj-$(CONFIG_UDELAY_IO) += udelay_io.o
obj-y += keyboard.o
-
+initobj-$(CONFIG_USE_OPTION_TABLE) += mc146818rtc_early.o
initobj-$(CONFIG_USE_DCACHE_RAM) += serial.o
subdirs-y += vga
diff --git a/src/pc80/mc146818rtc.c b/src/pc80/mc146818rtc.c
index 078bde273c..23b834c06a 100644
--- a/src/pc80/mc146818rtc.c
+++ b/src/pc80/mc146818rtc.c
@@ -1,11 +1,7 @@
#include <console/console.h>
-#include <arch/io.h>
#include <pc80/mc146818rtc.h>
#include <boot/coreboot_tables.h>
#include <string.h>
-#if CONFIG_HAVE_OPTION_TABLE
-#include <option_table.h>
-#endif
/* control registers - Moto names
*/
@@ -76,29 +72,7 @@
# define RTC_VRT 0x80 /* valid RAM and time */
/**********************************************************************/
-static inline unsigned char cmos_read(unsigned char addr)
-{
- int offs = 0;
- if (addr >= 128) {
- offs = 2;
- addr -= 128;
- }
- outb(addr, RTC_BASE_PORT + offs + 0);
- return inb(RTC_BASE_PORT + offs + 1);
-}
-
-static inline void cmos_write(unsigned char val, unsigned char addr)
-{
- int offs = 0;
- if (addr >= 128) {
- offs = 2;
- addr -= 128;
- }
- outb(addr, RTC_BASE_PORT + offs + 0);
- outb(val, RTC_BASE_PORT + offs + 1);
-}
-
-#if CONFIG_HAVE_OPTION_TABLE
+#if CONFIG_USE_OPTION_TABLE
static int rtc_checksum_valid(int range_start, int range_end, int cks_loc)
{
int i;
@@ -138,14 +112,14 @@ static void rtc_set_checksum(int range_start, int range_end, int cks_loc)
void rtc_init(int invalid)
{
-#if CONFIG_HAVE_OPTION_TABLE
+#if CONFIG_USE_OPTION_TABLE
unsigned char x;
int cmos_invalid, checksum_invalid;
#endif
printk(BIOS_DEBUG, "RTC Init\n");
-#if CONFIG_HAVE_OPTION_TABLE
+#if CONFIG_USE_OPTION_TABLE
/* See if there has been a CMOS power problem. */
x = cmos_read(RTC_VALID);
cmos_invalid = !(x & RTC_VRT);
@@ -186,7 +160,7 @@ void rtc_init(int invalid)
/* Setup the frequency it operates at */
cmos_write(RTC_FREQ_SELECT_DEFAULT, RTC_FREQ_SELECT);
-#if CONFIG_HAVE_OPTION_TABLE
+#if CONFIG_USE_OPTION_TABLE
/* See if there is a LB CMOS checksum error */
checksum_invalid = !rtc_checksum_valid(LB_CKS_RANGE_START,
LB_CKS_RANGE_END,LB_CKS_LOC);
@@ -203,7 +177,7 @@ void rtc_init(int invalid)
}
-#if CONFIG_USE_OPTION_TABLE == 1
+#if CONFIG_USE_OPTION_TABLE
/* This routine returns the value of the requested bits
input bit = bit count from the beginning of the cmos image
length = number of bits to include in the value
diff --git a/src/pc80/mc146818rtc_early.c b/src/pc80/mc146818rtc_early.c
index fa1f388804..ed1f0926f0 100644
--- a/src/pc80/mc146818rtc_early.c
+++ b/src/pc80/mc146818rtc_early.c
@@ -1,8 +1,5 @@
#include <pc80/mc146818rtc.h>
#include <fallback.h>
-#if CONFIG_HAVE_OPTION_TABLE
-#include <option_table.h>
-#endif
#ifndef CONFIG_MAX_REBOOT_CNT
#error "CONFIG_MAX_REBOOT_CNT not defined"
@@ -11,28 +8,6 @@
#error "CONFIG_MAX_REBOOT_CNT too high"
#endif
-static unsigned char cmos_read(unsigned char addr)
-{
- int offs = 0;
- if (addr >= 128) {
- offs = 2;
- addr -= 128;
- }
- outb(addr, RTC_BASE_PORT + offs + 0);
- return inb(RTC_BASE_PORT + offs + 1);
-}
-
-static void cmos_write(unsigned char val, unsigned char addr)
-{
- int offs = 0;
- if (addr >= 128) {
- offs = 2;
- addr -= 128;
- }
- outb(addr, RTC_BASE_PORT + offs + 0);
- outb(val, RTC_BASE_PORT + offs + 1);
-}
-
static int cmos_error(void)
{
unsigned char reg_d;
@@ -43,7 +18,7 @@ static int cmos_error(void)
static int cmos_chksum_valid(void)
{
-#if CONFIG_HAVE_OPTION_TABLE == 1
+#if CONFIG_USE_OPTION_TABLE
unsigned char addr;
unsigned long sum, old_sum;
sum = 0;
@@ -114,9 +89,9 @@ static inline int do_normal_boot(void)
return (byte & (1<<1));
}
-static inline unsigned read_option(unsigned start, unsigned size, unsigned def)
+unsigned read_option(unsigned start, unsigned size, unsigned def)
{
-#if CONFIG_USE_OPTION_TABLE == 1
+#if CONFIG_USE_OPTION_TABLE
unsigned byte;
byte = cmos_read(start/8);
return (byte >> (start & 7U)) & ((1U << size) - 1U);
diff --git a/src/pc80/serial.c b/src/pc80/serial.c
index 396a41914e..f7e4578221 100644
--- a/src/pc80/serial.c
+++ b/src/pc80/serial.c
@@ -1,5 +1,6 @@
#include <lib.h> /* Prototypes */
#include <arch/io.h>
+#include "pc80/mc146818rtc.h"
/* Base Address */
#ifndef CONFIG_TTYS0_BASE
@@ -80,7 +81,7 @@ void uart_init(void)
outb(0x01, CONFIG_TTYS0_BASE + UART_FCR);
/* Set Baud Rate Divisor to 12 ==> 115200 Baud */
outb(0x80 | UART_LCS, CONFIG_TTYS0_BASE + UART_LCR);
-#if CONFIG_USE_OPTION_TABLE == 1
+#if CONFIG_USE_OPTION_TABLE
static const unsigned char divisor[] = { 1,2,3,6,12,24,48,96 };
unsigned ttys0_div, ttys0_index;
ttys0_index = read_option(CMOS_VSTART_baud_rate, CMOS_VLEN_baud_rate, 0);
@@ -101,7 +102,7 @@ void uart_init(void)
extern void uart8250_init(unsigned base_port, unsigned divisor, unsigned lcs);
void uart_init(void)
{
-#if CONFIG_USE_OPTION_TABLE == 1
+#if CONFIG_USE_OPTION_TABLE
static const unsigned char divisor[] = { 1,2,3,6,12,24,48,96 };
unsigned ttys0_div, ttys0_index;
ttys0_index = read_option(CMOS_VSTART_baud_rate, CMOS_VLEN_baud_rate, 0);