Angel Pons | 6ad9176 | 2020-04-03 01:23:24 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Werner Zeh | 0dc87ef | 2019-10-22 15:08:19 +0200 | [diff] [blame] | 2 | |
| 3 | #include <arch/io.h> |
| 4 | #include <bootstate.h> |
| 5 | #include <cf9_reset.h> |
| 6 | #include <console/console.h> |
| 7 | #include <device/pci_def.h> |
| 8 | #include <device/pci_ids.h> |
| 9 | #include <device/pci_ops.h> |
| 10 | #include <gpio.h> |
| 11 | #include <hwilib.h> |
| 12 | #include <intelblocks/lpc_lib.h> |
| 13 | #include <intelblocks/pcr.h> |
| 14 | #include <soc/pcr_ids.h> |
Werner Zeh | 0dc87ef | 2019-10-22 15:08:19 +0200 | [diff] [blame] | 15 | #include <baseboard/variants.h> |
| 16 | #include <types.h> |
| 17 | |
| 18 | #define TX_DWORD3 0xa8c |
| 19 | |
| 20 | void variant_mainboard_final(void) |
| 21 | { |
| 22 | struct device *dev = NULL; |
Werner Zeh | 0dc87ef | 2019-10-22 15:08:19 +0200 | [diff] [blame] | 23 | |
| 24 | /* PIR6 register mapping for PCIe root ports |
| 25 | * INTA#->PIRQD#, INTB#->PIRQA#, INTC#->PIRQB#, INTD#-> PIRQC# |
| 26 | */ |
| 27 | pcr_write16(PID_ITSS, 0x314c, 0x2103); |
| 28 | |
| 29 | /* Enable CLKRUN_EN for power gating LPC */ |
| 30 | lpc_enable_pci_clk_cntl(); |
| 31 | |
| 32 | /* |
| 33 | * Enable LPC PCE (Power Control Enable) by setting IOSF-SB port 0xD2 |
| 34 | * offset 0x341D bit3 and bit0. |
| 35 | * Enable LPC CCE (Clock Control Enable) by setting IOSF-SB port 0xD2 |
| 36 | * offset 0x341C bit [3:0]. |
| 37 | */ |
| 38 | pcr_or32(PID_LPC, PCR_LPC_PRC, (PCR_LPC_CCE_EN | PCR_LPC_PCE_EN)); |
| 39 | |
| 40 | /* Set Master Enable for on-board PCI device. */ |
| 41 | dev = dev_find_device(PCI_VENDOR_ID_SIEMENS, 0x403e, 0); |
| 42 | if (dev) { |
Angel Pons | 28ed787 | 2020-11-10 20:07:33 +0100 | [diff] [blame] | 43 | pci_or_config16(dev, PCI_COMMAND, PCI_COMMAND_MASTER); |
Werner Zeh | 0dc87ef | 2019-10-22 15:08:19 +0200 | [diff] [blame] | 44 | |
Werner Zeh | 4f7fe49 | 2019-11-08 09:50:20 +0100 | [diff] [blame] | 45 | /* Disable clock outputs 0-3 (CLKOUT) for upstream |
Werner Zeh | 0dc87ef | 2019-10-22 15:08:19 +0200 | [diff] [blame] | 46 | * XIO2001 PCIe to PCI Bridge. |
| 47 | */ |
| 48 | struct device *parent = dev->bus->dev; |
| 49 | if (parent && parent->device == PCI_DEVICE_ID_TI_XIO2001) |
Werner Zeh | 4f7fe49 | 2019-11-08 09:50:20 +0100 | [diff] [blame] | 50 | pci_write_config8(parent, 0xd8, 0x0F); |
Werner Zeh | 0dc87ef | 2019-10-22 15:08:19 +0200 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | /* Disable clock outputs 2-5 (CLKOUT) for another XIO2001 PCIe to PCI |
| 54 | * Bridge on this mainboard. |
| 55 | */ |
| 56 | dev = dev_find_device(PCI_VENDOR_ID_SIEMENS, 0x403f, 0); |
| 57 | if (dev) { |
| 58 | struct device *parent = dev->bus->dev; |
| 59 | if (parent && parent->device == PCI_DEVICE_ID_TI_XIO2001) |
| 60 | pci_write_config8(parent, 0xd8, 0x3c); |
| 61 | } |
| 62 | |
| 63 | /* Set Full Reset Bit in Reset Control Register (I/O port CF9h). |
| 64 | * When Bit 3 is set to 1 and then the reset button is pressed the PCH |
| 65 | * will drive SLP_S3 active (low). SLP_S3 is then used on the mainboard |
| 66 | * to generate the right reset timing. |
| 67 | */ |
| 68 | outb(FULL_RST, RST_CNT); |
| 69 | } |
| 70 | |
Werner Zeh | 0dc87ef | 2019-10-22 15:08:19 +0200 | [diff] [blame] | 71 | static void finalize_boot(void *unused) |
| 72 | { |
| 73 | /* Set coreboot ready LED. */ |
| 74 | gpio_output(CNV_RGI_DT, 1); |
| 75 | } |
| 76 | |
Werner Zeh | 0dc87ef | 2019-10-22 15:08:19 +0200 | [diff] [blame] | 77 | BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_BOOT, BS_ON_ENTRY, finalize_boot, NULL); |