blob: ed2b18eaf2b153abadc36f9e3c10ec909f379352 [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
zbao246e84b2012-07-13 18:47:03 +08003
Elyes HAOUAS65fa5982014-07-22 23:12:38 +02004#ifndef _HUDSON_EARLY_SETUP_C_
5#define _HUDSON_EARLY_SETUP_C_
zbao246e84b2012-07-13 18:47:03 +08006
7#include <stdint.h>
Michał Żygowski287ce5f2019-12-01 17:41:23 +01008#include <amdblocks/acpimmio.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02009#include <device/pci_ops.h>
zbao246e84b2012-07-13 18:47:03 +080010#include <console/console.h>
Kyösti Mälkkia244d5e2019-12-09 08:08:58 +020011#include <amdblocks/acpimmio.h>
Elyes HAOUASeb789f02018-10-27 16:40:25 +020012
zbao246e84b2012-07-13 18:47:03 +080013#include "hudson.h"
14
Idwer Volleringc18e5212014-01-06 21:57:56 +000015void hudson_pci_port80(void)
16{
17 u8 byte;
Antonello Dettori8d7181d2016-09-01 16:50:42 +020018 pci_devfn_t dev;
Idwer Volleringc18e5212014-01-06 21:57:56 +000019
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
zbao246e84b2012-07-13 18:47:03 +080060void hudson_lpc_port80(void)
61{
62 u8 byte;
zbao246e84b2012-07-13 18:47:03 +080063
zbao246e84b2012-07-13 18:47:03 +080064 /* Enable port 80 LPC decode in pci function 3 configuration space. */
Elyes HAOUAS49f63e02020-04-22 16:14:26 +020065 const pci_devfn_t dev = PCI_DEV(0, 0x14, 3);
zbao246e84b2012-07-13 18:47:03 +080066 byte = pci_read_config8(dev, 0x4a);
Idwer Volleringc18e5212014-01-06 21:57:56 +000067 byte |= 1 << 5; /* enable port 80 */
zbao246e84b2012-07-13 18:47:03 +080068 pci_write_config8(dev, 0x4a, byte);
69}
70
Michał Żygowski8cee45c2019-11-23 18:03:46 +010071void hudson_lpc_decode(void)
72{
Michał Żygowski8cee45c2019-11-23 18:03:46 +010073 u32 tmp;
74
Kyösti Mälkkia244d5e2019-12-09 08:08:58 +020075 /* Enable LPC controller */
76 pm_write8(0xec, pm_read8(0xec) | 0x01);
77
Elyes HAOUAS49f63e02020-04-22 16:14:26 +020078 const pci_devfn_t dev = PCI_DEV(0, 0x14, 3);
Elyes HAOUAS4436ebe2020-01-08 13:04:59 +010079 /* Serial port enumeration on Hudson:
Michał Żygowski8cee45c2019-11-23 18:03:46 +010080 * 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'Callaghan893a55e2014-12-02 17:44:47 +110091#endif /* _HUDSON_EARLY_SETUP_C_ */