siemens/mc_apl1: Move board specific things to mc_apl1 variant
The following things are specific characteristic of mc_apl1 board
variant:
- initialization for the eDP to LVDS converter
- enable decoding address range for COM 3
- legacy IRQ routing for PCI devices
- wait function for old legacy devices
- set coreboot ready LED
Change-Id: I5c853e6caae6cc880ead436f232cabddeee6d09a
Signed-off-by: Mario Scheithauer <mario.scheithauer@siemens.com>
Reviewed-on: https://review.coreboot.org/25822
Reviewed-by: Werner Zeh <werner.zeh@siemens.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/src/mainboard/siemens/mc_apl1/Makefile.inc b/src/mainboard/siemens/mc_apl1/Makefile.inc
index ec4d0ad..c1ed753 100644
--- a/src/mainboard/siemens/mc_apl1/Makefile.inc
+++ b/src/mainboard/siemens/mc_apl1/Makefile.inc
@@ -6,7 +6,6 @@
romstage-y += romstage.c
ramstage-y += mainboard.c
-ramstage-y += ptn3460.c
subdirs-y += variants/baseboard
CPPFLAGS_common += -I$(src)/mainboard/$(MAINBOARDDIR)/variants/baseboard/include
diff --git a/src/mainboard/siemens/mc_apl1/mainboard.c b/src/mainboard/siemens/mc_apl1/mainboard.c
index ec110d8..09667cc 100644
--- a/src/mainboard/siemens/mc_apl1/mainboard.c
+++ b/src/mainboard/siemens/mc_apl1/mainboard.c
@@ -14,26 +14,19 @@
* GNU General Public License for more details.
*/
+#include <compiler.h>
#include <console/console.h>
-#include <delay.h>
#include <device/device.h>
#include <device/pci.h>
#include <device/pci_ids.h>
-#include <gpio.h>
#include <hwilib.h>
#include <i210.h>
#include <intelblocks/cpulib.h>
-#include <intelblocks/lpc_lib.h>
-#include <intelblocks/pcr.h>
#include <intelblocks/systemagent.h>
#include <soc/pci_devs.h>
-#include <soc/pcr_ids.h>
#include <string.h>
-#include <bootstate.h>
#include <timer.h>
-#include <timestamp.h>
#include <baseboard/variants.h>
-#include "ptn3460.h"
#define MAX_PATH_DEPTH 12
#define MAX_NUM_MAPPINGS 10
@@ -202,22 +195,11 @@
static void mainboard_final(void *chip_info)
{
- int status;
uint16_t cmd = 0;
device_t dev = NULL;
- /*
- * Set up the DP2LVDS converter.
- * ptn3460_init() may only be executed after i2c bus init.
- */
- status = ptn3460_init("hwinfo.hex");
- if (status)
- printk(BIOS_ERR, "LCD: Set up PTN with status 0x%x\n", status);
- else
- printk(BIOS_INFO, "LCD: Set up PTN was successful.\n");
-
- /* Enable additional I/O decoding range on LPC for COM 3 */
- lpc_open_pmio_window(0x3e8, 8);
+ /* Do board specific things */
+ variant_mainboard_final();
/* Set Master Enable for on-board PCI device. */
dev = dev_find_device(PCI_VENDOR_ID_SIEMENS, 0x403f, 0);
@@ -226,48 +208,13 @@
cmd |= PCI_COMMAND_MASTER;
pci_write_config16(dev, PCI_COMMAND, cmd);
}
-
- /*
- * PIR6 register mapping for PCIe root ports
- * INTA#->PIRQB#, INTB#->PIRQC#, INTC#->PIRQD#, INTD#-> PIRQA#
- */
- pcr_write16(PID_ITSS, 0x314c, 0x0321);
}
-static void wait_for_legacy_dev(void *unused)
+/* The following function performs board specific things. */
+void __weak variant_mainboard_final(void)
{
- uint32_t legacy_delay, us_since_boot;
- struct stopwatch sw;
-
- /* Open main hwinfo block. */
- if (hwilib_find_blocks("hwinfo.hex") != CB_SUCCESS)
- return;
-
- /* Get legacy delay parameter from hwinfo. */
- if (hwilib_get_field(LegacyDelay, (uint8_t *) &legacy_delay,
- sizeof(legacy_delay)) != sizeof(legacy_delay))
- return;
-
- us_since_boot = get_us_since_boot();
- /* No need to wait if the time since boot is already long enough.*/
- if (us_since_boot > legacy_delay)
- return;
- stopwatch_init_msecs_expire(&sw, (legacy_delay - us_since_boot) / 1000);
- printk(BIOS_NOTICE, "Wait remaining %d of %d us for legacy devices...",
- legacy_delay - us_since_boot, legacy_delay);
- stopwatch_wait_until_expired(&sw);
- printk(BIOS_NOTICE, "done!\n");
}
-static void finalize_boot(void *unused)
-{
- /* Set coreboot ready LED. */
- gpio_output(CNV_RGI_DT, 1);
-}
-
-BOOT_STATE_INIT_ENTRY(BS_DEV_ENUMERATE, BS_ON_ENTRY, wait_for_legacy_dev, NULL);
-BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_BOOT, BS_ON_ENTRY, finalize_boot, NULL);
-
struct chip_operations mainboard_ops = {
.init = mainboard_init,
.final = mainboard_final,
diff --git a/src/mainboard/siemens/mc_apl1/variants/baseboard/include/baseboard/variants.h b/src/mainboard/siemens/mc_apl1/variants/baseboard/include/baseboard/variants.h
index 8061d97..09153c6 100644
--- a/src/mainboard/siemens/mc_apl1/variants/baseboard/include/baseboard/variants.h
+++ b/src/mainboard/siemens/mc_apl1/variants/baseboard/include/baseboard/variants.h
@@ -26,4 +26,7 @@
const struct pad_config *variant_gpio_table(size_t *num);
const struct pad_config *variant_early_gpio_table(size_t *num);
+/* The following function performs board specific things. */
+void variant_mainboard_final(void);
+
#endif /* _BASEBOARD_VARIANTS_H_ */
diff --git a/src/mainboard/siemens/mc_apl1/variants/mc_apl1/Makefile.inc b/src/mainboard/siemens/mc_apl1/variants/mc_apl1/Makefile.inc
new file mode 100644
index 0000000..adf9aff
--- /dev/null
+++ b/src/mainboard/siemens/mc_apl1/variants/mc_apl1/Makefile.inc
@@ -0,0 +1,2 @@
+ramstage-y += mainboard.c
+ramstage-y += ptn3460.c
diff --git a/src/mainboard/siemens/mc_apl1/ptn3460.h b/src/mainboard/siemens/mc_apl1/variants/mc_apl1/include/variant/ptn3460.h
similarity index 100%
rename from src/mainboard/siemens/mc_apl1/ptn3460.h
rename to src/mainboard/siemens/mc_apl1/variants/mc_apl1/include/variant/ptn3460.h
diff --git a/src/mainboard/siemens/mc_apl1/variants/mc_apl1/mainboard.c b/src/mainboard/siemens/mc_apl1/variants/mc_apl1/mainboard.c
new file mode 100644
index 0000000..540e322
--- /dev/null
+++ b/src/mainboard/siemens/mc_apl1/variants/mc_apl1/mainboard.c
@@ -0,0 +1,84 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2018 Siemens AG
+ *
+ * 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.
+ */
+
+#include <bootstate.h>
+#include <console/console.h>
+#include <gpio.h>
+#include <hwilib.h>
+#include <intelblocks/lpc_lib.h>
+#include <intelblocks/pcr.h>
+#include <soc/pcr_ids.h>
+#include <timer.h>
+#include <timestamp.h>
+#include <baseboard/variants.h>
+#include <variant/ptn3460.h>
+
+void variant_mainboard_final(void)
+{
+ int status;
+
+ /*
+ * Set up the DP2LVDS converter.
+ * ptn3460_init() may only be executed after i2c bus init.
+ */
+ status = ptn3460_init("hwinfo.hex");
+ if (status)
+ printk(BIOS_ERR, "LCD: Set up PTN with status 0x%x\n", status);
+ else
+ printk(BIOS_INFO, "LCD: Set up PTN was successful.\n");
+
+ /* Enable additional I/O decoding range on LPC for COM 3 */
+ lpc_open_pmio_window(0x3e8, 8);
+
+ /*
+ * PIR6 register mapping for PCIe root ports
+ * INTA#->PIRQB#, INTB#->PIRQC#, INTC#->PIRQD#, INTD#-> PIRQA#
+ */
+ pcr_write16(PID_ITSS, 0x314c, 0x0321);
+}
+
+static void wait_for_legacy_dev(void *unused)
+{
+ uint32_t legacy_delay, us_since_boot;
+ struct stopwatch sw;
+
+ /* Open main hwinfo block. */
+ if (hwilib_find_blocks("hwinfo.hex") != CB_SUCCESS)
+ return;
+
+ /* Get legacy delay parameter from hwinfo. */
+ if (hwilib_get_field(LegacyDelay, (uint8_t *) &legacy_delay,
+ sizeof(legacy_delay)) != sizeof(legacy_delay))
+ return;
+
+ us_since_boot = get_us_since_boot();
+ /* No need to wait if the time since boot is already long enough.*/
+ if (us_since_boot > legacy_delay)
+ return;
+ stopwatch_init_msecs_expire(&sw, (legacy_delay - us_since_boot) / 1000);
+ printk(BIOS_NOTICE, "Wait remaining %d of %d us for legacy devices...",
+ legacy_delay - us_since_boot, legacy_delay);
+ stopwatch_wait_until_expired(&sw);
+ printk(BIOS_NOTICE, "done!\n");
+}
+
+static void finalize_boot(void *unused)
+{
+ /* Set coreboot ready LED. */
+ gpio_output(CNV_RGI_DT, 1);
+}
+
+BOOT_STATE_INIT_ENTRY(BS_DEV_ENUMERATE, BS_ON_ENTRY, wait_for_legacy_dev, NULL);
+BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_BOOT, BS_ON_ENTRY, finalize_boot, NULL);
diff --git a/src/mainboard/siemens/mc_apl1/ptn3460.c b/src/mainboard/siemens/mc_apl1/variants/mc_apl1/ptn3460.c
similarity index 99%
rename from src/mainboard/siemens/mc_apl1/ptn3460.c
rename to src/mainboard/siemens/mc_apl1/variants/mc_apl1/ptn3460.c
index 1877e8b..f1cbf0f 100644
--- a/src/mainboard/siemens/mc_apl1/ptn3460.c
+++ b/src/mainboard/siemens/mc_apl1/variants/mc_apl1/ptn3460.c
@@ -17,7 +17,7 @@
#include <lib.h>
#include <hwilib.h>
#include <device/i2c_simple.h>
-#include "ptn3460.h"
+#include <variant/ptn3460.h>
/**
* This function sets up the DP2LVDS-converter to be used with the appropriate