Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 3 | |
Elyes HAOUAS | 65fa598 | 2014-07-22 23:12:38 +0200 | [diff] [blame] | 4 | #ifndef _HUDSON_EARLY_SETUP_C_ |
| 5 | #define _HUDSON_EARLY_SETUP_C_ |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 6 | |
| 7 | #include <stdint.h> |
Michał Żygowski | 287ce5f | 2019-12-01 17:41:23 +0100 | [diff] [blame] | 8 | #include <amdblocks/acpimmio.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 9 | #include <device/pci_ops.h> |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 10 | #include <console/console.h> |
Kyösti Mälkki | a244d5e | 2019-12-09 08:08:58 +0200 | [diff] [blame] | 11 | #include <amdblocks/acpimmio.h> |
Elyes HAOUAS | eb789f0 | 2018-10-27 16:40:25 +0200 | [diff] [blame] | 12 | |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 13 | #include "hudson.h" |
| 14 | |
Idwer Vollering | c18e521 | 2014-01-06 21:57:56 +0000 | [diff] [blame] | 15 | void hudson_pci_port80(void) |
| 16 | { |
| 17 | u8 byte; |
Antonello Dettori | 8d7181d | 2016-09-01 16:50:42 +0200 | [diff] [blame] | 18 | pci_devfn_t dev; |
Idwer Vollering | c18e521 | 2014-01-06 21:57:56 +0000 | [diff] [blame] | 19 | |
| 20 | /* P2P Bridge */ |
| 21 | dev = PCI_DEV(0, 0x14, 4); |
| 22 | |
| 23 | /* Chip Control: Enable subtractive decoding */ |
| 24 | byte = pci_read_config8(dev, 0x40); |
| 25 | byte |= 1 << 5; |
| 26 | pci_write_config8(dev, 0x40, byte); |
| 27 | |
| 28 | /* Misc Control: Enable subtractive decoding if 0x40 bit 5 is set */ |
| 29 | byte = pci_read_config8(dev, 0x4B); |
| 30 | byte |= 1 << 7; |
| 31 | pci_write_config8(dev, 0x4B, byte); |
| 32 | |
| 33 | /* The same IO Base and IO Limit here is meaningful because we set the |
| 34 | * bridge to be subtractive. During early setup stage, we have to make |
| 35 | * sure that data can go through port 0x80. |
| 36 | */ |
| 37 | /* IO Base: 0xf000 */ |
| 38 | byte = pci_read_config8(dev, 0x1C); |
| 39 | byte |= 0xF << 4; |
| 40 | pci_write_config8(dev, 0x1C, byte); |
| 41 | |
| 42 | /* IO Limit: 0xf000 */ |
| 43 | byte = pci_read_config8(dev, 0x1D); |
| 44 | byte |= 0xF << 4; |
| 45 | pci_write_config8(dev, 0x1D, byte); |
| 46 | |
| 47 | /* PCI Command: Enable IO response */ |
| 48 | byte = pci_read_config8(dev, 0x04); |
| 49 | byte |= 1 << 0; |
| 50 | pci_write_config8(dev, 0x04, byte); |
| 51 | |
| 52 | /* LPC controller */ |
| 53 | dev = PCI_DEV(0, 0x14, 3); |
| 54 | |
| 55 | byte = pci_read_config8(dev, 0x4A); |
| 56 | byte &= ~(1 << 5); /* disable lpc port 80 */ |
| 57 | pci_write_config8(dev, 0x4A, byte); |
| 58 | } |
| 59 | |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 60 | void hudson_lpc_port80(void) |
| 61 | { |
| 62 | u8 byte; |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 63 | |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 64 | /* Enable port 80 LPC decode in pci function 3 configuration space. */ |
Elyes HAOUAS | 49f63e0 | 2020-04-22 16:14:26 +0200 | [diff] [blame^] | 65 | const pci_devfn_t dev = PCI_DEV(0, 0x14, 3); |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 66 | byte = pci_read_config8(dev, 0x4a); |
Idwer Vollering | c18e521 | 2014-01-06 21:57:56 +0000 | [diff] [blame] | 67 | byte |= 1 << 5; /* enable port 80 */ |
zbao | 246e84b | 2012-07-13 18:47:03 +0800 | [diff] [blame] | 68 | pci_write_config8(dev, 0x4a, byte); |
| 69 | } |
| 70 | |
Michał Żygowski | 8cee45c | 2019-11-23 18:03:46 +0100 | [diff] [blame] | 71 | void hudson_lpc_decode(void) |
| 72 | { |
Michał Żygowski | 8cee45c | 2019-11-23 18:03:46 +0100 | [diff] [blame] | 73 | u32 tmp; |
| 74 | |
Kyösti Mälkki | a244d5e | 2019-12-09 08:08:58 +0200 | [diff] [blame] | 75 | /* Enable LPC controller */ |
| 76 | pm_write8(0xec, pm_read8(0xec) | 0x01); |
| 77 | |
Elyes HAOUAS | 49f63e0 | 2020-04-22 16:14:26 +0200 | [diff] [blame^] | 78 | const pci_devfn_t dev = PCI_DEV(0, 0x14, 3); |
Elyes HAOUAS | 4436ebe | 2020-01-08 13:04:59 +0100 | [diff] [blame] | 79 | /* Serial port enumeration on Hudson: |
Michał Żygowski | 8cee45c | 2019-11-23 18:03:46 +0100 | [diff] [blame] | 80 | * PORT0 - 0x3f8 |
| 81 | * PORT1 - 0x2f8 |
| 82 | * PORT5 - 0x2e8 |
| 83 | * PORT7 - 0x3e8 |
| 84 | */ |
| 85 | tmp = DECODE_ENABLE_SERIAL_PORT0 | DECODE_ENABLE_SERIAL_PORT1 |
| 86 | | DECODE_ENABLE_SERIAL_PORT5 | DECODE_ENABLE_SERIAL_PORT7; |
| 87 | |
| 88 | pci_write_config32(dev, LPC_IO_PORT_DECODE_ENABLE, tmp); |
| 89 | } |
| 90 | |
Edward O'Callaghan | 893a55e | 2014-12-02 17:44:47 +1100 | [diff] [blame] | 91 | #endif /* _HUDSON_EARLY_SETUP_C_ */ |