Timothy Pearson | 53538be | 2015-04-30 01:47:31 -0500 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering |
| 5 | * Copyright (C) 2014 Edward O'Callaghan <eocallaghan@alterapraxis.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
Timothy Pearson | 53538be | 2015-04-30 01:47:31 -0500 | [diff] [blame] | 16 | */ |
| 17 | |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 18 | #include <device/pci_ops.h> |
Timothy Pearson | 53538be | 2015-04-30 01:47:31 -0500 | [diff] [blame] | 19 | #include <pc80/mc146818rtc.h> |
| 20 | |
| 21 | void bootblock_mainboard_init(void) |
| 22 | { |
| 23 | uint8_t recovery_enabled; |
| 24 | unsigned char addr; |
| 25 | unsigned char byte; |
| 26 | |
| 27 | bootblock_northbridge_init(); |
| 28 | bootblock_southbridge_init(); |
| 29 | |
| 30 | /* Recovery jumper is connected to SP5100 GPIO61, and clears the GPIO when placed in the Recovery position */ |
Timothy Pearson | 369b561 | 2015-12-06 00:47:17 -0600 | [diff] [blame] | 31 | byte = pci_io_read_config8(PCI_DEV(0, 0x14, 0), 0x56); |
| 32 | byte |= 0x1 << 4; /* Set GPIO61 to input mode */ |
| 33 | pci_io_write_config8(PCI_DEV(0, 0x14, 0), 0x56, byte); |
| 34 | recovery_enabled = (!(pci_io_read_config8(PCI_DEV(0, 0x14, 0), 0x57) & 0x1)); |
Timothy Pearson | 53538be | 2015-04-30 01:47:31 -0500 | [diff] [blame] | 35 | if (recovery_enabled) { |
Martin Roth | f95911a | 2017-06-24 21:45:13 -0600 | [diff] [blame] | 36 | #if IS_ENABLED(CONFIG_USE_OPTION_TABLE) |
Timothy Pearson | 53538be | 2015-04-30 01:47:31 -0500 | [diff] [blame] | 37 | /* Clear NVRAM checksum */ |
| 38 | for (addr = LB_CKS_RANGE_START; addr <= LB_CKS_RANGE_END; addr++) { |
| 39 | cmos_write(0x0, addr); |
| 40 | } |
| 41 | |
| 42 | /* Set fallback boot */ |
| 43 | byte = cmos_read(RTC_BOOT_BYTE); |
| 44 | byte &= 0xfc; |
| 45 | cmos_write(byte, RTC_BOOT_BYTE); |
| 46 | #else |
| 47 | /* FIXME |
| 48 | * Figure out how to recover if the option table is not available |
| 49 | */ |
| 50 | #endif |
| 51 | } |
Timothy Pearson | 369b561 | 2015-12-06 00:47:17 -0600 | [diff] [blame] | 52 | } |