Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5337
-gerrit
commit d5d79d97e2a35726de370839ed6a2dbebcf187ca
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Mon Feb 3 17:04:22 2014 +0200
console: Drop driver list in ramstage
This framework was only available in ramstage. So we had to define
console output functions separately for bootblock, romstage and SMM.
Follow-up patches will re-enable all the consoles removed here,
in a more flexible fashion, and with less lines-of-code and copy-paste.
Also the driver list is not in a well-defined order and some of the
loops could exit without visiting all drivers.
NOTE: This build has no console in ramstage.
Change-Id: Iaddc495aaca37e2a6c2c3f802a0dba27bf227a3e
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
src/arch/armv7/coreboot_ram.ld | 4 ---
src/arch/x86/coreboot_ram.ld | 4 ---
src/console/Makefile.inc | 8 -----
src/console/cbmem_console.c | 36 --------------------
src/console/console.c | 65 +++++--------------------------------
src/console/ne2k_console.c | 37 ---------------------
src/console/qemu_debugcon_console.c | 37 ---------------------
src/console/spkmodem_console.c | 46 --------------------------
src/console/uart_console.c | 59 ---------------------------------
src/console/usbdebug_console.c | 56 --------------------------------
src/drivers/uart/uart8250io.c | 5 ---
src/drivers/uart/uart8250mem.c | 8 -----
src/include/console/console.h | 18 ----------
src/include/console/uart.h | 1 -
src/lib/rmodule.ld | 4 ---
15 files changed, 9 insertions(+), 379 deletions(-)
diff --git a/src/arch/armv7/coreboot_ram.ld b/src/arch/armv7/coreboot_ram.ld
index 38eaca3..452d2d7 100644
--- a/src/arch/armv7/coreboot_ram.ld
+++ b/src/arch/armv7/coreboot_ram.ld
@@ -56,10 +56,6 @@ SECTIONS
.rodata : {
_rodata = .;
. = ALIGN(4);
- console_drivers = .;
- *(.rodata.console_drivers)
- econsole_drivers = . ;
- . = ALIGN(4);
pci_drivers = . ;
*(.rodata.pci_driver)
epci_drivers = . ;
diff --git a/src/arch/x86/coreboot_ram.ld b/src/arch/x86/coreboot_ram.ld
index ea32837..1d1143c 100644
--- a/src/arch/x86/coreboot_ram.ld
+++ b/src/arch/x86/coreboot_ram.ld
@@ -54,10 +54,6 @@ SECTIONS
/* If any changes are made to the driver start/symbols or the
* section names the equivalent changes need to made to
* rmodule.ld. */
- console_drivers = .;
- *(.rodata.console_drivers)
- econsole_drivers = . ;
- . = ALIGN(4);
pci_drivers = . ;
*(.rodata.pci_driver)
epci_drivers = . ;
diff --git a/src/console/Makefile.inc b/src/console/Makefile.inc
index ef917da..d59e44e 100644
--- a/src/console/Makefile.inc
+++ b/src/console/Makefile.inc
@@ -15,14 +15,6 @@ bootblock-$(CONFIG_BOOTBLOCK_CONSOLE) += vtxprintf.c printk.c
bootblock-$(CONFIG_BOOTBLOCK_CONSOLE) += init.c console.c
bootblock-y += die.c
-ramstage-$(CONFIG_CONSOLE_SERIAL) += uart_console.c
-ramstage-$(CONFIG_SPKMODEM) += spkmodem_console.c
-ramstage-$(CONFIG_CONSOLE_USB) += usbdebug_console.c
-ramstage-$(CONFIG_CONSOLE_NE2K) += ne2k_console.c
-ramstage-$(CONFIG_CONSOLE_CBMEM) += cbmem_console.c
-ramstage-$(CONFIG_CONSOLE_QEMU_DEBUGCON) += qemu_debugcon_console.c
-
-
$(obj)/console/init.ramstage.o : $(obj)/build.h
$(obj)/console/init.romstage.o : $(obj)/build.h
$(obj)/console/init.bootblock.o : $(obj)/build.h
diff --git a/src/console/cbmem_console.c b/src/console/cbmem_console.c
deleted file mode 100644
index 870ce2f..0000000
--- a/src/console/cbmem_console.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
- *
- * 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; version 2 of the License.
- *
- * 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/cbmem_console.h>
-
-static void cbmemc_init_(void)
-{
- cbmemc_init();
-}
-
-static void cbmemc_tx_byte_(unsigned char data)
-{
- cbmemc_tx_byte(data);
-}
-
-static const struct console_driver cbmem_console __console = {
- .init = cbmemc_init_,
- .tx_byte = cbmemc_tx_byte_,
-};
diff --git a/src/console/console.c b/src/console/console.c
index d5aadf6..2f4eb5c 100644
--- a/src/console/console.c
+++ b/src/console/console.c
@@ -24,62 +24,6 @@
#include <console/ne2k.h>
#include <console/spkmodem.h>
-#ifndef __PRE_RAM__
-
-/* initialize the console */
-void console_hw_init(void)
-{
- struct console_driver *driver;
-
- for(driver = console_drivers; driver < econsole_drivers; driver++) {
- if (!driver->init)
- continue;
- driver->init();
- }
-}
-
-void console_tx_flush(void)
-{
- struct console_driver *driver;
- for(driver = console_drivers; driver < econsole_drivers; driver++) {
- if (!driver->tx_flush)
- continue;
- driver->tx_flush();
- }
-}
-
-void console_tx_byte(unsigned char byte)
-{
- struct console_driver *driver;
- for(driver = console_drivers; driver < econsole_drivers; driver++) {
- driver->tx_byte(byte);
- }
-}
-
-unsigned char console_rx_byte(void)
-{
- struct console_driver *driver;
- for(driver = console_drivers; driver < econsole_drivers; driver++) {
- if (driver->tst_byte)
- break;
- }
- if (driver == econsole_drivers)
- return 0;
- while (!driver->tst_byte());
- return driver->rx_byte();
-}
-
-int console_tst_byte(void)
-{
- struct console_driver *driver;
- for(driver = console_drivers; driver < econsole_drivers; driver++)
- if (driver->tst_byte)
- return driver->tst_byte();
- return 0;
-}
-
-#else // __PRE_RAM__ ^^^ NOT defined vvv defined
-
void console_hw_init(void)
{
#if CONFIG_CONSOLE_SERIAL
@@ -98,4 +42,13 @@ void console_hw_init(void)
usbdebug_init();
#endif
}
+
+#ifndef __PRE_RAM__
+void console_tx_byte(unsigned char byte)
+{
+}
+
+void console_tx_flush(void)
+{
+}
#endif
diff --git a/src/console/ne2k_console.c b/src/console/ne2k_console.c
deleted file mode 100644
index ffbf0c6..0000000
--- a/src/console/ne2k_console.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2010 Advanced Micro Devices, Inc.
- * Copyright (C) 2010 Rudolf Marek <r.marek(a)assembler.cz>
- *
- * 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; version 2 of the License.
- *
- * 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/ne2k.h>
-
-static void ne2k_tx_byte(unsigned char data)
-{
- ne2k_append_data(&data, 1, CONFIG_CONSOLE_NE2K_IO_PORT);
-}
-
-static void ne2k_tx_flush(void)
-{
- ne2k_transmit(CONFIG_CONSOLE_NE2K_IO_PORT);
-}
-
-static const struct console_driver ne2k_console __console = {
- .tx_byte = ne2k_tx_byte,
- .tx_flush = ne2k_tx_flush,
-};
diff --git a/src/console/qemu_debugcon_console.c b/src/console/qemu_debugcon_console.c
deleted file mode 100644
index d7a53a2..0000000
--- a/src/console/qemu_debugcon_console.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2013 Red Hat Inc.
- * Written by Gerd Hoffmann <kraxel(a)redhat.com>
- *
- * 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; version 2 of the License.
- *
- * 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/qemu_debugcon.h>
-
-static void debugcon_init(void)
-{
- qemu_debugcon_init();
-}
-
-static void debugcon_tx_byte(unsigned char data)
-{
- qemu_debugcon_tx_byte(data);
-}
-
-static const struct console_driver debugcon_console __console = {
- .init = debugcon_init,
- .tx_byte = debugcon_tx_byte,
-};
diff --git a/src/console/spkmodem_console.c b/src/console/spkmodem_console.c
deleted file mode 100644
index 814a1ac..0000000
--- a/src/console/spkmodem_console.c
+++ /dev/null
@@ -1,46 +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 <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/console/uart_console.c b/src/console/uart_console.c
deleted file mode 100644
index f5535d7..0000000
--- a/src/console/uart_console.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2003 Eric Biederman
- *
- * 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; version 2 of the License.
- *
- * 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/uart.h>
-
-static void uartmem_init(void)
-{
- uart_init();
-}
-
-static void uartmem_tx_byte(unsigned char data)
-{
- uart_tx_byte(data);
-}
-
-static void uartmem_tx_flush(void)
-{
- uart_tx_flush();
-}
-
-static unsigned char uartmem_rx_byte(void)
-{
- return uart_rx_byte();
-}
-
-/* This only relevant with x86 with GDB_STUB enabled.*/
-static int uartmem_tst_byte(void)
-{
-#if CONFIG_DRIVERS_UART_8250IO || CONFIG_DRIVERS_UART_8250MEM
- return uart_can_rx_byte();
-#else
- return 0;
-#endif
-}
-
-static const struct console_driver uart_console __console = {
- .init = uartmem_init,
- .tx_byte = uartmem_tx_byte,
- .tx_flush = uartmem_tx_flush,
- .rx_byte = uartmem_rx_byte,
- .tst_byte = uartmem_tst_byte,
-};
diff --git a/src/console/usbdebug_console.c b/src/console/usbdebug_console.c
deleted file mode 100644
index 8331473..0000000
--- a/src/console/usbdebug_console.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2007 AMD
- * Written by Yinghai Lu <yinghai.lu(a)amd.com> for AMD.
- *
- * 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; version 2 of the License.
- *
- * 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 <string.h>
-#include <console/console.h>
-#include <console/usb.h>
-
-static void dbgp_init(void)
-{
- usbdebug_init();
-}
-
-static void dbgp_tx_byte(unsigned char data)
-{
- usb_tx_byte(0, data);
-}
-
-static unsigned char dbgp_rx_byte(void)
-{
- return usb_rx_byte(0);
-}
-
-static void dbgp_tx_flush(void)
-{
- usb_tx_flush(0);
-}
-
-static int dbgp_tst_byte(void)
-{
- return usb_can_rx_byte(0);
-}
-
-static const struct console_driver usbdebug_direct_console __console = {
- .init = dbgp_init,
- .tx_byte = dbgp_tx_byte,
- .tx_flush = dbgp_tx_flush,
- .rx_byte = dbgp_rx_byte,
- .tst_byte = dbgp_tst_byte,
-};
diff --git a/src/drivers/uart/uart8250io.c b/src/drivers/uart/uart8250io.c
index 1eebb18..e1fb39b 100644
--- a/src/drivers/uart/uart8250io.c
+++ b/src/drivers/uart/uart8250io.c
@@ -129,11 +129,6 @@ unsigned char uart_rx_byte(void)
return uart8250_rx_byte(bases[0]);
}
-int uart_can_rx_byte(void)
-{
- return uart8250_can_rx_byte(bases[0]);
-}
-
void uart_tx_flush(void)
{
uart8250_tx_flush(bases[0]);
diff --git a/src/drivers/uart/uart8250mem.c b/src/drivers/uart/uart8250mem.c
index 74929f5..5a186f0 100644
--- a/src/drivers/uart/uart8250mem.c
+++ b/src/drivers/uart/uart8250mem.c
@@ -116,14 +116,6 @@ unsigned char uart_rx_byte(void)
return uart8250_mem_rx_byte(base);
}
-int uart_can_rx_byte(void)
-{
- u32 base = uart_platform_base(0);
- if (!base)
- return 0;
- return uart8250_mem_can_rx_byte(base);
-}
-
void uart_tx_flush(void)
{
u32 base = uart_platform_base(0);
diff --git a/src/include/console/console.h b/src/include/console/console.h
index c184f83..0ebd1b7 100644
--- a/src/include/console/console.h
+++ b/src/include/console/console.h
@@ -24,24 +24,6 @@
#include <console/loglevel.h>
#include <console/post_codes.h>
-#ifndef __PRE_RAM__
-unsigned char console_rx_byte(void);
-int console_tst_byte(void);
-struct console_driver {
- void (*init)(void);
- void (*tx_byte)(unsigned char byte);
- void (*tx_flush)(void);
- unsigned char (*rx_byte)(void);
- int (*tst_byte)(void);
-};
-
-#define __console __attribute__((used, __section__ (".rodata.console_drivers")))
-
-/* Defined by the linker... */
-extern struct console_driver console_drivers[];
-extern struct console_driver econsole_drivers[];
-#endif
-
#ifndef __ROMCC__
int console_log_level(int msg_level);
void console_init(void);
diff --git a/src/include/console/uart.h b/src/include/console/uart.h
index 8987d94..05cc432 100644
--- a/src/include/console/uart.h
+++ b/src/include/console/uart.h
@@ -43,7 +43,6 @@ void uart_init(void);
void uart_tx_byte(unsigned char data);
void uart_tx_flush(void);
unsigned char uart_rx_byte(void);
-int uart_can_rx_byte(void);
unsigned int uart_platform_base(int idx);
diff --git a/src/lib/rmodule.ld b/src/lib/rmodule.ld
index 9222f3b..63b99b3 100644
--- a/src/lib/rmodule.ld
+++ b/src/lib/rmodule.ld
@@ -35,10 +35,6 @@ SECTIONS
/* The driver sections are to allow linking coreboot's
* ramstage with the rmodule linker. Any changes made in
* coreboot_ram.ld should be made here as well. */
- console_drivers = .;
- *(.rodata.console_drivers)
- econsole_drivers = . ;
- . = ALIGN(4);
pci_drivers = . ;
*(.rodata.pci_driver)
epci_drivers = . ;
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5237
-gerrit
commit 784b6b38d4fa2fa15f924aea4a7bbe96e3e5bbe7
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Fri Feb 14 12:45:09 2014 +0200
OxPCIe uart: Split PCI bridge control
None of the PCI bridge management here is specific to the PCI UART
device/function. Also the Kconfig variable defaults are not globally
valid, fill samsung/lumpy with working values.
Change-Id: Id22631412379af1d6bf62c996357d36d7ec47ca3
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
src/console/console.c | 12 +++-
src/device/Kconfig | 29 +++++++++
src/device/Makefile.inc | 1 +
src/device/pci_early.c | 104 +++++++++++++++++++++++++++++++
src/drivers/oxford/oxpcie/Kconfig | 64 +------------------
src/drivers/oxford/oxpcie/oxpcie_early.c | 89 ++++++--------------------
src/include/console/uart.h | 1 -
src/include/device/pci.h | 2 +
src/mainboard/samsung/lumpy/Kconfig | 16 +++++
9 files changed, 183 insertions(+), 135 deletions(-)
diff --git a/src/console/console.c b/src/console/console.c
index 9e9e4e2..348264d 100644
--- a/src/console/console.c
+++ b/src/console/console.c
@@ -28,6 +28,11 @@
#include <arch/hlt.h>
#include <arch/io.h>
+#if CONFIG_EARLY_PCI_BRIDGE
+/* FIXME: ROMCC chokes on PCI headers. */
+#include <device/pci.h>
+#endif
+
#ifndef __PRE_RAM__
#include <string.h>
#include <types.h>
@@ -40,6 +45,9 @@ void console_init(void)
if(get_option(&console_loglevel, "debug_level") != CB_SUCCESS)
console_loglevel=CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
+#if CONFIG_EARLY_PCI_BRIDGE
+ pci_early_bridge_init();
+#endif
for(driver = console_drivers; driver < econsole_drivers; driver++) {
if (!driver->init)
continue;
@@ -101,8 +109,8 @@ void console_init(void)
#if defined(__BOOT_BLOCK__) && CONFIG_BOOTBLOCK_CONSOLE || \
!defined(__BOOT_BLOCK__) && CONFIG_EARLY_CONSOLE
-#if CONFIG_DRIVERS_OXFORD_OXPCIE
- oxford_init();
+#if CONFIG_EARLY_PCI_BRIDGE
+ pci_early_bridge_init();
#endif
#if CONFIG_CONSOLE_SERIAL
uart_init();
diff --git a/src/device/Kconfig b/src/device/Kconfig
index eaa0c04..932b4de 100644
--- a/src/device/Kconfig
+++ b/src/device/Kconfig
@@ -237,6 +237,35 @@ config PCIEXP_ASPM
config PCI_BUS_SEGN_BITS
int
default 0
+
+config EARLY_PCI_BRIDGE
+ bool "Early PCI bridge"
+ depends on PCI
+ default n
+ help
+ While coreboot is executing code from ROM, the coreboot resource
+ allocator has not been running yet. Hence PCI devices living behind
+ a bridge are not yet visible to the system.
+
+ This option enables static configuration for a single pre-defined
+ PCI bridge function on bus 0.
+
+if EARLY_PCI_BRIDGE
+
+config EARLY_PCI_BRIDGE_DEVICE
+ hex "bridge device"
+ default 0x0
+
+config EARLY_PCI_BRIDGE_FUNCTION
+ hex "bridge function"
+ default 0x0
+
+config EARLY_PCI_MMIO_BASE
+ hex "MMIO window base"
+ default 0x0
+
+endif # EARLY_PCI_BRIDGE
+
endmenu
menu "VGA BIOS"
diff --git a/src/device/Makefile.inc b/src/device/Makefile.inc
index ce412b7..bd41b12 100644
--- a/src/device/Makefile.inc
+++ b/src/device/Makefile.inc
@@ -11,6 +11,7 @@ ramstage-$(CONFIG_CARDBUS_PLUGIN_SUPPORT) += cardbus_device.c
ramstage-$(CONFIG_AZALIA_PLUGIN_SUPPORT) += azalia_device.c
ramstage-$(CONFIG_ARCH_X86) += pnp_device.c
ramstage-$(CONFIG_PCI) += pci_ops.c
+ramstage-$(CONFIG_PCI) += pci_early.c
ramstage-y += smbus_ops.c
romstage-y += device_romstage.c
diff --git a/src/device/pci_early.c b/src/device/pci_early.c
index c15a4d0..e31287e 100644
--- a/src/device/pci_early.c
+++ b/src/device/pci_early.c
@@ -1,6 +1,8 @@
/*
* This file is part of the coreboot project.
*
+ * Copyright (C) 2011 Google Inc
+ *
* 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; version 2 of the License.
@@ -15,9 +17,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
*/
+#define __SIMPLE_DEVICE__
+
#include <arch/io.h>
#include <device/pci.h>
#include <device/pci_def.h>
+#include <delay.h>
+
+#ifdef __PRE_RAM__
unsigned pci_find_next_capability(device_t dev, unsigned cap, unsigned last)
{
@@ -66,3 +73,100 @@ unsigned pci_find_capability(device_t dev, unsigned cap)
{
return pci_find_next_capability(dev, cap, 0);
}
+#endif
+
+
+#if CONFIG_EARLY_PCI_BRIDGE
+
+static void pci_bridge_reset_secondary(device_t p2p_bridge)
+{
+ u16 reg16;
+
+ /* First we reset the secondary bus. */
+ reg16 = pci_read_config16(p2p_bridge, PCI_BRIDGE_CONTROL);
+ reg16 |= (1 << 6); /* SRESET */
+ pci_write_config16(p2p_bridge, PCI_BRIDGE_CONTROL, reg16);
+
+ /* Assume we don't have to wait here forever */
+
+ /* Read back and clear reset bit. */
+ reg16 = pci_read_config16(p2p_bridge, PCI_BRIDGE_CONTROL);
+ reg16 &= ~(1 << 6); /* SRESET */
+ pci_write_config16(p2p_bridge, PCI_BRIDGE_CONTROL, reg16);
+}
+
+static void pci_bridge_set_secondary(device_t p2p_bridge, u8 secondary)
+{
+ /* Disable config transaction forwarding. */
+ pci_write_config8(p2p_bridge, PCI_SECONDARY_BUS, 0x00);
+ pci_write_config8(p2p_bridge, PCI_SUBORDINATE_BUS, 0x00);
+ /* Enable config transaction forwarding. */
+ pci_write_config8(p2p_bridge, PCI_SECONDARY_BUS, secondary);
+ pci_write_config8(p2p_bridge, PCI_SUBORDINATE_BUS, secondary);
+}
+
+static void pci_bridge_set_mmio(device_t p2p_bridge, u32 base, u32 size)
+{
+ u16 reg16;
+
+ /* Disable MMIO window behind the bridge. */
+ reg16 = pci_read_config16(p2p_bridge, PCI_COMMAND);
+ reg16 &= ~PCI_COMMAND_MEMORY;
+ pci_write_config16(p2p_bridge, PCI_COMMAND, reg16);
+ pci_write_config32(p2p_bridge, PCI_MEMORY_BASE, 0x10);
+
+ if (!size)
+ return;
+
+ /* Enable MMIO window behind the bridge. */
+ pci_write_config32(p2p_bridge, PCI_MEMORY_BASE,
+ ((base + size - 1) & 0xfff00000) | ((base >> 16) & 0xfff0));
+
+ reg16 = pci_read_config16(p2p_bridge, PCI_COMMAND);
+ reg16 |= PCI_COMMAND_MEMORY;
+ pci_write_config16(p2p_bridge, PCI_COMMAND, reg16);
+}
+
+void pci_early_bridge_init(void)
+{
+ int timeout, ret = -1;
+
+ /* No PCI-to-PCI bridges are enabled yet, so the one we try to
+ * configure must have its primary on bus 0.
+ */
+ pci_devfn_t p2p_bridge = PCI_DEV(0, CONFIG_EARLY_PCI_BRIDGE_DEVICE,
+ CONFIG_EARLY_PCI_BRIDGE_FUNCTION);
+
+ /* Secondary bus number is mostly irrelevant as we disable
+ * configuration transactions right after the probe.
+ */
+ u8 secondary = 15;
+ u8 dev = 0;
+ u32 mmio_base = CONFIG_EARLY_PCI_MMIO_BASE;
+
+ /* Enable configuration and MMIO over bridge. */
+ pci_bridge_reset_secondary(p2p_bridge);
+ pci_bridge_set_secondary(p2p_bridge, secondary);
+ pci_bridge_set_mmio(p2p_bridge, mmio_base, 0x4000);
+
+ for (timeout = 20000; timeout; timeout--) {
+ u32 id = pci_read_config32(PCI_DEV(secondary, dev, 0), PCI_VENDOR_ID);
+ if (id != 0 && id != 0xffffffff && id != 0xffff0001)
+ break;
+ udelay(10);
+ }
+
+ if (timeout != 0)
+ ret = pci_early_device_probe(secondary, dev, mmio_base);
+
+ /* Disable MMIO window if we found no suitable device. */
+ if (ret)
+ pci_bridge_set_mmio(p2p_bridge, 0, 0);
+
+ /* Resource allocator will reconfigure bridges and secondary bus
+ * number may change. Thus early device cannot reliably use config
+ * transactions from here on, so we may as well disable them.
+ */
+ pci_bridge_set_secondary(p2p_bridge, 0);
+}
+#endif /* CONFIG_EARLY_PCI_BRIDGE */
diff --git a/src/drivers/oxford/oxpcie/Kconfig b/src/drivers/oxford/oxpcie/Kconfig
index 5ad42aa..c2ea7b6 100644
--- a/src/drivers/oxford/oxpcie/Kconfig
+++ b/src/drivers/oxford/oxpcie/Kconfig
@@ -1,68 +1,10 @@
config DRIVERS_OXFORD_OXPCIE
bool "Oxford OXPCIe952"
default n
+ depends on PCI
select DRIVERS_UART_8250MEM
+ select EARLY_PCI_BRIDGE
help
Support for Oxford OXPCIe952 serial port PCIe cards.
Currently only devices with the vendor ID 0x1415 and device ID
- 0xc158 will work.
- NOTE: Right now you have to set the base address of your OXPCIe952
- card to exactly the value that the device allocator would set them
- later on, or serial console functionality will stop as soon as the
- resource allocator assigns a new base address to the device.
-
-config OXFORD_OXPCIE_BRIDGE_BUS
- hex "OXPCIe's PCIe bridge bus number"
- default 0x0
- depends on DRIVERS_OXFORD_OXPCIE
- help
- While coreboot is executing code from ROM, the coreboot resource
- allocator has not been running yet. Hence PCI devices living behind
- a bridge are not yet visible to the system. In order to use an
- OXPCIe952 based PCIe card, coreboot has to set up the PCIe bridge
- that controls the OXPCIe952 controller first.
-
-config OXFORD_OXPCIE_BRIDGE_DEVICE
- hex "OXPCIe's PCIe bridge device number"
- default 0x1c
- depends on DRIVERS_OXFORD_OXPCIE
- help
- While coreboot is executing code from ROM, the coreboot resource
- allocator has not been running yet. Hence PCI devices living behind
- a bridge are not yet visible to the system. In order to use an
- OXPCIe952 based PCIe card, coreboot has to set up the PCIe bridge
- that controls the OXPCIe952 controller first.
-
-config OXFORD_OXPCIE_BRIDGE_FUNCTION
- hex "OXPCIe's PCIe bridge function number"
- default 0x2
- depends on DRIVERS_OXFORD_OXPCIE
- help
- While coreboot is executing code from ROM, the coreboot resource
- allocator has not been running yet. Hence PCI devices living behind
- a bridge are not yet visible to the system. In order to use an
- OXPCIe952 based PCIe card, coreboot has to set up the PCIe bridge
- that controls the OXPCIe952 controller first.
-
-config OXFORD_OXPCIE_BRIDGE_SUBORDINATE
- hex "OXPCIe's PCIe bridge subordinate bus"
- default 0x3
- depends on DRIVERS_OXFORD_OXPCIE
- help
- While coreboot is executing code from ROM, the coreboot resource
- allocator has not been running yet. Hence PCI devices living behind
- a bridge are not yet visible to the system. In order to use an
- OXPCIe952 based PCIe card, coreboot has to set up the PCIe bridge
- that controls the OXPCIe952 controller first.
-
-config OXFORD_OXPCIE_BASE_ADDRESS
- hex "Base address for rom stage console"
- default 0xe0400000
- depends on DRIVERS_OXFORD_OXPCIE
- help
- While coreboot is executing code from ROM, the coreboot resource
- allocator has not been running yet. Hence PCI devices living behind
- a bridge are not yet visible to the system. In order to use an
- OXPCIe952 based PCIe card, coreboot has to set up a temporary address
- for the OXPCIe952 controller.
-
+ 0xc158 or 0xc11b will work.
diff --git a/src/drivers/oxford/oxpcie/oxpcie_early.c b/src/drivers/oxford/oxpcie/oxpcie_early.c
index 7de9da6..b81fa89 100644
--- a/src/drivers/oxford/oxpcie/oxpcie_early.c
+++ b/src/drivers/oxford/oxpcie/oxpcie_early.c
@@ -23,101 +23,53 @@
#include <stddef.h>
#include <arch/io.h>
#include <arch/early_variables.h>
-#include <delay.h>
#include <boot/coreboot_tables.h>
#include <console/uart.h>
#include <device/pci.h>
#include <device/pci_def.h>
static unsigned int oxpcie_present CAR_GLOBAL;
-static ROMSTAGE_CONST u32 uart0_base = CONFIG_OXFORD_OXPCIE_BASE_ADDRESS + 0x1000;
-static ROMSTAGE_CONST u32 uart1_base = CONFIG_OXFORD_OXPCIE_BASE_ADDRESS + 0x2000;
+static ROMSTAGE_CONST u32 uart0_base = CONFIG_EARLY_PCI_MMIO_BASE + 0x1000;
+static ROMSTAGE_CONST u32 uart1_base = CONFIG_EARLY_PCI_MMIO_BASE + 0x2000;
-#define PCIE_BRIDGE \
- PCI_DEV(CONFIG_OXFORD_OXPCIE_BRIDGE_BUS, \
- CONFIG_OXFORD_OXPCIE_BRIDGE_DEVICE, \
- CONFIG_OXFORD_OXPCIE_BRIDGE_FUNCTION)
-
-#define OXPCIE_DEVICE \
- PCI_DEV(CONFIG_OXFORD_OXPCIE_BRIDGE_SUBORDINATE, 0, 0)
-
-#define OXPCIE_DEVICE_3 \
- PCI_DEV(CONFIG_OXFORD_OXPCIE_BRIDGE_SUBORDINATE, 0, 3)
-
-static void oxpcie_init_bridge(void)
+int pci_early_device_probe(u8 bus, u8 dev, u32 mmio_base)
{
- u16 reg16;
-
- /* First we reset the secondary bus */
- reg16 = pci_read_config16(PCIE_BRIDGE, PCI_BRIDGE_CONTROL);
- reg16 |= (1 << 6); /* SRESET */
- pci_write_config16(PCIE_BRIDGE, PCI_BRIDGE_CONTROL, reg16);
-
- /* Assume we don't have to wait here forever */
+ pci_devfn_t device = PCI_DEV(bus, dev, 0);
- /* Read back and clear reset bit. */
- reg16 = pci_read_config16(PCIE_BRIDGE, PCI_BRIDGE_CONTROL);
- reg16 &= ~(1 << 6); /* SRESET */
- pci_write_config16(PCIE_BRIDGE, PCI_BRIDGE_CONTROL, reg16);
-
- /* Set up subordinate bus number */
- pci_write_config8(PCIE_BRIDGE, PCI_SECONDARY_BUS, 0x00);
- pci_write_config8(PCIE_BRIDGE, PCI_SUBORDINATE_BUS, 0x00);
- pci_write_config8(PCIE_BRIDGE, PCI_SECONDARY_BUS,
- CONFIG_OXFORD_OXPCIE_BRIDGE_SUBORDINATE);
- pci_write_config8(PCIE_BRIDGE, PCI_SUBORDINATE_BUS,
- CONFIG_OXFORD_OXPCIE_BRIDGE_SUBORDINATE);
-
- /* Memory window for the OXPCIe952 card */
- // XXX is the calculation of base and limit correct?
- pci_write_config32(PCIE_BRIDGE, PCI_MEMORY_BASE,
- ((CONFIG_OXFORD_OXPCIE_BASE_ADDRESS & 0xffff0000) |
- ((CONFIG_OXFORD_OXPCIE_BASE_ADDRESS >> 16) & 0xff00)));
-
- /* Enable memory access through bridge */
- reg16 = pci_read_config16(PCIE_BRIDGE, PCI_COMMAND);
- reg16 |= PCI_COMMAND_MEMORY;
- pci_write_config16(PCIE_BRIDGE, PCI_COMMAND, reg16);
-
- u32 timeout = 20000; // Timeout in 10s of microseconds.
- u32 id = 0;
- for (;;) {
- id = pci_read_config32(OXPCIE_DEVICE, PCI_VENDOR_ID);
- if (!timeout-- || (id != 0 && id != 0xffffffff))
- break;
- udelay(10);
- }
-
- u32 device = OXPCIE_DEVICE; /* unknown default */
+ u32 id = pci_read_config32(device, PCI_VENDOR_ID);
switch (id) {
- case 0xc1181415: /* e.g. Startech PEX1S1PMINI */
+ case 0xc1181415: /* e.g. Startech PEX1S1PMINI function 0 */
/* On this device function 0 is the parallel port, and
* function 3 is the serial port. So let's go look for
* the UART.
*/
- id = pci_read_config32(OXPCIE_DEVICE_3, PCI_VENDOR_ID);
+ device = PCI_DEV(bus, dev, 3);
+ id = pci_read_config32(device, PCI_VENDOR_ID);
if (id != 0xc11b1415)
- return;
- device = OXPCIE_DEVICE_3;
+ return -1;
break;
+ case 0xc11b1415: /* e.g. Startech PEX1S1PMINI function 3 */
case 0xc1581415: /* e.g. Startech MPEX2S952 */
- device = OXPCIE_DEVICE;
break;
default:
/* No UART here. */
- return;
+ return -1;
}
+ /* Sanity-check, we assume fixed location. */
+ if (mmio_base != CONFIG_EARLY_PCI_MMIO_BASE)
+ return -1;
+
/* Setup base address on device */
- pci_write_config32(device, PCI_BASE_ADDRESS_0,
- CONFIG_OXFORD_OXPCIE_BASE_ADDRESS);
+ pci_write_config32(device, PCI_BASE_ADDRESS_0, mmio_base);
/* Enable memory on device */
- reg16 = pci_read_config16(device, PCI_COMMAND);
+ u16 reg16 = pci_read_config16(device, PCI_COMMAND);
reg16 |= PCI_COMMAND_MEMORY;
pci_write_config16(device, PCI_COMMAND, reg16);
car_set_var(oxpcie_present, 1);
+ return 0;
}
static int oxpcie_uart_active(void)
@@ -157,8 +109,3 @@ unsigned int uart_platform_refclk(void)
{
return 62500000;
}
-
-void oxford_init(void)
-{
- oxpcie_init_bridge();
-}
diff --git a/src/include/console/uart.h b/src/include/console/uart.h
index 5650618..8987d94 100644
--- a/src/include/console/uart.h
+++ b/src/include/console/uart.h
@@ -52,7 +52,6 @@ static inline void *uart_platform_baseptr(int idx)
return (void *)uart_platform_base(idx);
}
-void oxford_init(void);
void oxford_remap(unsigned int new_base);
#endif /* CONSOLE_UART_H */
diff --git a/src/include/device/pci.h b/src/include/device/pci.h
index 29d988f..f729c27 100644
--- a/src/include/device/pci.h
+++ b/src/include/device/pci.h
@@ -102,6 +102,8 @@ static inline const struct pci_operations *ops_pci(device_t dev)
unsigned pci_find_next_capability(device_t dev, unsigned cap, unsigned last);
unsigned pci_find_capability(device_t dev, unsigned cap);
+void pci_early_bridge_init(void);
+int pci_early_device_probe(u8 bus, u8 dev, u32 mmio_base);
#endif /* CONFIG_PCI */
diff --git a/src/mainboard/samsung/lumpy/Kconfig b/src/mainboard/samsung/lumpy/Kconfig
index 032b4b5..500427a 100644
--- a/src/mainboard/samsung/lumpy/Kconfig
+++ b/src/mainboard/samsung/lumpy/Kconfig
@@ -46,4 +46,20 @@ config MAINBOARD_POWER_ON_AFTER_POWER_FAIL
bool
default n
+if EARLY_PCI_BRIDGE
+
+config EARLY_PCI_BRIDGE_DEVICE
+ hex
+ default 0x1c
+
+config EARLY_PCI_BRIDGE_FUNCTION
+ hex
+ default 0x0
+
+config EARLY_PCI_MMIO_BASE
+ hex
+ default 0xe0400000
+
+endif
+
endif # BOARD_SAMSUNG_LUMPY