| 1 |
|
| 2 |
|
| 3 |
#ifndef AMD_BLOCK_LPC_H |
| 4 |
#define AMD_BLOCK_LPC_H |
| 5 |
|
| 6 |
#include <types.h> |
| 7 |
|
| 8 |
|
| 9 |
#define LPC_PCI_CONTROL 0x40 |
| 10 |
#define LEGACY_DMA_EN BIT(2) |
| 11 |
#define VW_ROM_SHARING_EN BIT(3) |
| 12 |
#define EXT_ROM_SHARING_EN BIT(4) |
| 13 |
#define SPI_ROM_BIOS_SEMAPHORE BIT(5) |
| 14 |
#define SPI_ROM_EC_SEMAPHORE BIT(6) |
| 15 |
|
| 16 |
#define LPC_IO_PORT_DECODE_ENABLE 0x44 |
| 17 |
#define DECODE_ENABLE_PARALLEL_PORT0 BIT(0) |
| 18 |
#define DECODE_ENABLE_PARALLEL_PORT1 BIT(1) |
| 19 |
#define DECODE_ENABLE_PARALLEL_PORT2 BIT(2) |
| 20 |
#define DECODE_ENABLE_PARALLEL_PORT3 BIT(3) |
| 21 |
#define DECODE_ENABLE_PARALLEL_PORT4 BIT(4) |
| 22 |
#define DECODE_ENABLE_PARALLEL_PORT5 BIT(5) |
| 23 |
#define DECODE_ENABLE_SERIAL_PORT0 BIT(6) |
| 24 |
#define DECODE_ENABLE_SERIAL_PORT1 BIT(7) |
| 25 |
#define DECODE_ENABLE_SERIAL_PORT2 BIT(8) |
| 26 |
#define DECODE_ENABLE_SERIAL_PORT3 BIT(9) |
| 27 |
#define DECODE_ENABLE_SERIAL_PORT4 BIT(10) |
| 28 |
#define DECODE_ENABLE_SERIAL_PORT5 BIT(11) |
| 29 |
#define DECODE_ENABLE_SERIAL_PORT6 BIT(12) |
| 30 |
#define DECODE_ENABLE_SERIAL_PORT7 BIT(13) |
| 31 |
#define DECODE_ENABLE_AUDIO_PORT0 BIT(14) |
| 32 |
#define DECODE_ENABLE_AUDIO_PORT1 BIT(15) |
| 33 |
#define DECODE_ENABLE_AUDIO_PORT2 BIT(16) |
| 34 |
#define DECODE_ENABLE_AUDIO_PORT3 BIT(17) |
| 35 |
#define DECODE_ENABLE_MIDI_PORT0 BIT(18) |
| 36 |
#define DECODE_ENABLE_MIDI_PORT1 BIT(19) |
| 37 |
#define DECODE_ENABLE_MIDI_PORT2 BIT(20) |
| 38 |
#define DECODE_ENABLE_MIDI_PORT3 BIT(21) |
| 39 |
#define DECODE_ENABLE_MSS_PORT0 BIT(22) |
| 40 |
#define DECODE_ENABLE_MSS_PORT1 BIT(23) |
| 41 |
#define DECODE_ENABLE_MSS_PORT2 BIT(24) |
| 42 |
#define DECODE_ENABLE_MSS_PORT3 BIT(25) |
| 43 |
#define DECODE_ENABLE_FDC_PORT0 BIT(26) |
| 44 |
#define DECODE_ENABLE_FDC_PORT1 BIT(27) |
| 45 |
#define DECODE_ENABLE_GAME_PORT BIT(28) |
| 46 |
#define DECODE_ENABLE_KBC_PORT BIT(29) |
| 47 |
#define DECODE_ENABLE_ACPIUC_PORT BIT(30) |
| 48 |
#define DECODE_ENABLE_ADLIB_PORT BIT(31) |
| 49 |
|
| 50 |
#define LPC_IO_OR_MEM_DECODE_ENABLE 0x48 |
| 51 |
#define LPC_WIDEIO2_ENABLE BIT(25) |
| 52 |
#define LPC_WIDEIO1_ENABLE BIT(24) |
| 53 |
#define DECODE_IO_PORT_ENABLE6 BIT(23) |
| 54 |
#define DECODE_IO_PORT_ENABLE5 BIT(22) |
| 55 |
#define DECODE_IO_PORT_ENABLE4 BIT(21) |
| 56 |
#define DECODE_MEM_PORT_ENABLE1 BIT(20) |
| 57 |
#define DECODE_IO_PORT_ENABLE3 BIT(19) |
| 58 |
#define DECODE_IO_PORT_ENABLE2 BIT(18) |
| 59 |
#define DECODE_IO_PORT_ENABLE1 BIT(17) |
| 60 |
#define DECODE_IO_PORT_ENABLE0 BIT(16) |
| 61 |
#define LPC_SYNC_TIMEOUT_COUNT_MASK (0xff << 8) |
| 62 |
#define LPC_SYNC_TIMEOUT_COUNT_ENABLE BIT(7) |
| 63 |
#define LPC_DECODE_RTC_IO_ENABLE BIT(6) |
| 64 |
#define DECODE_MEM_PORT_ENABLE0 BIT(5) |
| 65 |
#define LPC_WIDEIO0_ENABLE BIT(2) |
| 66 |
#define DECODE_ALTERNATE_SIO_ENABLE BIT(1) |
| 67 |
#define DECODE_SIO_ENABLE BIT(0) |
| 68 |
#define LPC_SELECT_SIO_4E4F 1 |
| 69 |
#define LPC_SELECT_SIO_2E2F 0 |
| 70 |
#define WIDEIO_RANGE_ERROR -1 |
| 71 |
|
| 72 |
#define LPC_MEM_PORT1 0x4c |
| 73 |
#define ROM_PROTECT_RANGE0 0x50 |
| 74 |
#define ROM_BASE_MASK 0xfffff000 |
| 75 |
#define ROM_RANGE_WP BIT(10) |
| 76 |
#define ROM_RANGE_RP BIT(9) |
| 77 |
#define RANGE_UNIT BIT(8) |
| 78 |
#define RANGE_ADDR_MASK 0x000000ff |
| 79 |
#define ROM_PROTECT_RANGE_REG(n) (ROM_PROTECT_RANGE0 + (4 * n)) |
| 80 |
#define MAX_ROM_PROTECT_RANGES 4 |
| 81 |
#define LPC_MEM_PORT0 0x60 |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
#define LPC_WIDEIO_GENERIC_PORT 0x64 |
| 86 |
#define LPC_WIDEIO1_GENERIC_PORT 0x66 |
| 87 |
#define ROM_ADDRESS_RANGE1_START 0x68 |
| 88 |
#define ROM_ADDRESS_RANGE1_END 0x6a |
| 89 |
#define ROM_ADDRESS_RANGE2_START 0x6c |
| 90 |
#define ROM_ADDRESS_RANGE2_END 0x6e |
| 91 |
|
| 92 |
#define LPC_ALT_WIDEIO_RANGE_ENABLE 0x74 |
| 93 |
#define LPC_ALT_WIDEIO2_ENABLE BIT(3) |
| 94 |
#define LPC_ALT_WIDEIO1_ENABLE BIT(2) |
| 95 |
#define LPC_ALT_WIDEIO0_ENABLE BIT(0) |
| 96 |
|
| 97 |
#define LPC_MISC_CONTROL_BITS 0x78 |
| 98 |
#define LPC_LDRQ1_EN BIT(3) |
| 99 |
#define LPC_LDRQ0_EN BIT(2) |
| 100 |
#define LPC_NOHOG BIT(0) |
| 101 |
|
| 102 |
#define LPC_TRUSTED_PLATFORM_MODULE 0x7c |
| 103 |
#define TPM_12_EN BIT(0) |
| 104 |
#define TPM_LEGACY_EN BIT(2) |
| 105 |
|
| 106 |
#define LPC_WIDEIO2_GENERIC_PORT 0x90 |
| 107 |
|
| 108 |
#define ROM_ADDRESS_RANGE3_START 0xa8 |
| 109 |
|
| 110 |
#define LPC_ROM_DMA_SRC_ADDR 0xb0 |
| 111 |
#define LPC_ROM_DMA_DST_ADDR 0xb4 |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
#define LPC_ROM_DMA_EC_HOST_CONTROL 0xb8 |
| 116 |
#define SPI_FROM_HOST_PREFETCH_EN BIT(24) |
| 117 |
#define SPI_FROM_USB_PREFETCH_EN BIT(23) |
| 118 |
#define LPC_ROM_DMA_CTRL_DW_COUNT_SHIFT 6 |
| 119 |
#define LPC_ROM_DMA_CTRL_DW_COUNT_MASK (0x3ffUL << LPC_ROM_DMA_CTRL_DW_COUNT_SHIFT) |
| 120 |
#define LPC_ROM_DMA_CTRL_ERROR BIT(1) |
| 121 |
#define LPC_ROM_DMA_CTRL_START BIT(0) |
| 122 |
#define LPC_ROM_DMA_MIN_ALIGNMENT (1 << 6) |
| 123 |
#define LPC_ROM_DMA_CTRL_DW_COUNT(bytes) \ |
| 124 |
(((bytes / LPC_ROM_DMA_MIN_ALIGNMENT) - 1) << LPC_ROM_DMA_CTRL_DW_COUNT_SHIFT) |
| 125 |
#define LPC_ROM_DMA_CTRL_MAX_BYTES \ |
| 126 |
(((LPC_ROM_DMA_CTRL_DW_COUNT_MASK >> LPC_ROM_DMA_CTRL_DW_COUNT_SHIFT) + 1) \ |
| 127 |
* LPC_ROM_DMA_MIN_ALIGNMENT) |
| 128 |
|
| 129 |
#define LPC_HOST_CONTROL 0xbb |
| 130 |
#define PREFETCH_EN_SPI_FROM_HOST BIT(0) |
| 131 |
#define T_START_ENH BIT(3) |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
void lpc_disable_decodes(void); |
| 136 |
void lpc_enable_port80(void); |
| 137 |
void lpc_enable_decode(uint32_t decodes); |
| 138 |
|
| 139 |
void lpc_enable_sio_decode(const bool addr); |
| 140 |
uintptr_t lpc_spibase(void); |
| 141 |
void lpc_tpm_decode(void); |
| 142 |
void lpc_tpm_decode_spi(void); |
| 143 |
void lpc_enable_rom(void); |
| 144 |
void lpc_enable_spi_prefetch(void); |
| 145 |
uint32_t lpc_get_rom2_region(size_t *bios_size); |
| 146 |
uint64_t lpc_get_rom3_region(size_t *bios_size); |
| 147 |
|
| 148 |
void lpc_disable_spi_rom_sharing(void); |
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
uint16_t lpc_wideio_size(int index); |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
int lpc_find_wideio_range(uint16_t start, uint16_t size); |
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
int lpc_set_wideio_range(uint16_t start, uint16_t size); |
| 176 |
|
| 177 |
uintptr_t lpc_get_spibase(void); |
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
void lpc_early_init(void); |
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
void lpc_set_spibase(uint32_t base); |
| 194 |
|
| 195 |
|
| 196 |
void lpc_enable_spi_rom(uint32_t enable); |
| 197 |
|
| 198 |
#endif |