Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2010 Advanced Micro Devices, Inc. |
| 5 | * Copyright (C) 2014 Sage Electronic Engineering, LLC |
| 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; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #ifndef HUDSON_H |
| 18 | #define HUDSON_H |
| 19 | |
Marshall Dawson | d8019a6 | 2017-01-29 17:22:36 -0700 | [diff] [blame] | 20 | #include <types.h> |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 21 | #include <device/device.h> |
| 22 | #include "chip.h" |
| 23 | |
Marc Jones | d771786 | 2017-04-09 17:55:56 -0600 | [diff] [blame] | 24 | /* Offsets from ACPI_MMIO_BASE |
| 25 | * This is defined by AGESA, but we don't include AGESA headers to avoid |
| 26 | * polluting the namespace. |
| 27 | */ |
Marshall Dawson | c1f3233 | 2017-04-21 13:54:08 -0600 | [diff] [blame] | 28 | #define PM_MMIO_BASE 0xfed80300 |
Marc Jones | d771786 | 2017-04-09 17:55:56 -0600 | [diff] [blame] | 29 | |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 30 | /* Power management index/data registers */ |
Marshall Dawson | c1f3233 | 2017-04-21 13:54:08 -0600 | [diff] [blame] | 31 | #define BIOSRAM_INDEX 0xcd4 |
| 32 | #define BIOSRAM_DATA 0xcd5 |
| 33 | #define PM_INDEX 0xcd6 |
| 34 | #define PM_DATA 0xcd7 |
| 35 | #define PM2_INDEX 0xcd0 |
| 36 | #define PM2_DATA 0xcd1 |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 37 | |
Marshall Dawson | c1f3233 | 2017-04-21 13:54:08 -0600 | [diff] [blame] | 38 | #define PM_ACPI_MMIO_EN 0x24 |
| 39 | #define PM_SERIRQ_CONF 0x54 |
| 40 | #define PM_EVT_BLK 0x60 |
| 41 | #define PM1_CNT_BLK 0x62 |
| 42 | #define PM_TMR_BLK 0x64 |
| 43 | #define PM_CPU_CTRL 0x66 |
| 44 | #define PM_GPE0_BLK 0x68 |
| 45 | #define PM_ACPI_SMI_CMD 0x6A |
| 46 | #define PM_ACPI_CONF 0x74 |
| 47 | #define PM_PMIO_DEBUG 0xD2 |
| 48 | #define PM_MANUAL_RESET 0xD3 |
| 49 | #define PM_HUD_SD_FLASH_CTRL 0xE7 |
| 50 | #define PM_YANG_SD_FLASH_CTRL 0xE8 |
| 51 | #define PM_PCIB_CFG 0xEA |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 52 | |
Marc Jones | 7f2c29b | 2017-04-26 21:55:03 -0600 | [diff] [blame] | 53 | #define HUDSON_ACPI_IO_BASE CONFIG_HUDSON_ACPI_IO_BASE |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 54 | #define ACPI_PM_EVT_BLK (HUDSON_ACPI_IO_BASE + 0x00) /* 4 bytes */ |
| 55 | #define ACPI_PM1_CNT_BLK (HUDSON_ACPI_IO_BASE + 0x04) /* 2 bytes */ |
| 56 | #define ACPI_PM_TMR_BLK (HUDSON_ACPI_IO_BASE + 0x18) /* 4 bytes */ |
| 57 | #define ACPI_GPE0_BLK (HUDSON_ACPI_IO_BASE + 0x10) /* 8 bytes */ |
| 58 | #define ACPI_CPU_CONTROL (HUDSON_ACPI_IO_BASE + 0x08) /* 6 bytes */ |
| 59 | |
| 60 | #define ACPI_SMI_CTL_PORT 0xb2 |
| 61 | #define ACPI_SMI_CMD_CST_CONTROL 0xde |
| 62 | #define ACPI_SMI_CMD_PST_CONTROL 0xad |
| 63 | #define ACPI_SMI_CMD_DISABLE 0xbe |
| 64 | #define ACPI_SMI_CMD_ENABLE 0xef |
| 65 | #define ACPI_SMI_CMD_S4_REQ 0xc0 |
| 66 | |
Marshall Dawson | c1f3233 | 2017-04-21 13:54:08 -0600 | [diff] [blame] | 67 | #define REV_HUDSON_A11 0x11 |
| 68 | #define REV_HUDSON_A12 0x12 |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 69 | |
Marshall Dawson | c1f3233 | 2017-04-21 13:54:08 -0600 | [diff] [blame] | 70 | #define SPIROM_BASE_ADDRESS_REGISTER 0xA0 |
Marc Jones | 6fcaaef | 2017-04-20 16:48:42 -0600 | [diff] [blame] | 71 | #define ROUTE_TPM_2_SPI BIT(3) |
Marshall Dawson | c1f3233 | 2017-04-21 13:54:08 -0600 | [diff] [blame] | 72 | #define SPI_ROM_ENABLE 0x02 |
| 73 | #define SPI_BASE_ADDRESS 0xFEC10000 |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 74 | |
Marshall Dawson | c1f3233 | 2017-04-21 13:54:08 -0600 | [diff] [blame] | 75 | #define LPC_IO_PORT_DECODE_ENABLE 0x44 |
| 76 | #define DECODE_ENABLE_PARALLEL_PORT0 BIT(0) |
| 77 | #define DECODE_ENABLE_PARALLEL_PORT1 BIT(1) |
| 78 | #define DECODE_ENABLE_PARALLEL_PORT2 BIT(2) |
| 79 | #define DECODE_ENABLE_PARALLEL_PORT3 BIT(3) |
| 80 | #define DECODE_ENABLE_PARALLEL_PORT4 BIT(4) |
| 81 | #define DECODE_ENABLE_PARALLEL_PORT5 BIT(5) |
| 82 | #define DECODE_ENABLE_SERIAL_PORT0 BIT(6) |
| 83 | #define DECODE_ENABLE_SERIAL_PORT1 BIT(7) |
| 84 | #define DECODE_ENABLE_SERIAL_PORT2 BIT(8) |
| 85 | #define DECODE_ENABLE_SERIAL_PORT3 BIT(9) |
| 86 | #define DECODE_ENABLE_SERIAL_PORT4 BIT(10) |
| 87 | #define DECODE_ENABLE_SERIAL_PORT5 BIT(11) |
| 88 | #define DECODE_ENABLE_SERIAL_PORT6 BIT(12) |
| 89 | #define DECODE_ENABLE_SERIAL_PORT7 BIT(13) |
| 90 | #define DECODE_ENABLE_AUDIO_PORT0 BIT(14) |
| 91 | #define DECODE_ENABLE_AUDIO_PORT1 BIT(15) |
| 92 | #define DECODE_ENABLE_AUDIO_PORT2 BIT(16) |
| 93 | #define DECODE_ENABLE_AUDIO_PORT3 BIT(17) |
| 94 | #define DECODE_ENABLE_MIDI_PORT0 BIT(18) |
| 95 | #define DECODE_ENABLE_MIDI_PORT1 BIT(19) |
| 96 | #define DECODE_ENABLE_MIDI_PORT2 BIT(20) |
| 97 | #define DECODE_ENABLE_MIDI_PORT3 BIT(21) |
| 98 | #define DECODE_ENABLE_MSS_PORT0 BIT(22) |
| 99 | #define DECODE_ENABLE_MSS_PORT1 BIT(23) |
| 100 | #define DECODE_ENABLE_MSS_PORT2 BIT(24) |
| 101 | #define DECODE_ENABLE_MSS_PORT3 BIT(25) |
| 102 | #define DECODE_ENABLE_FDC_PORT0 BIT(26) |
| 103 | #define DECODE_ENABLE_FDC_PORT1 BIT(27) |
| 104 | #define DECODE_ENABLE_GAME_PORT BIT(28) |
| 105 | #define DECODE_ENABLE_KBC_PORT BIT(29) |
| 106 | #define DECODE_ENABLE_ACPIUC_PORT BIT(30) |
| 107 | #define DECODE_ENABLE_ADLIB_PORT BIT(31) |
Dave Frodin | f364fc7 | 2015-03-13 08:22:17 -0600 | [diff] [blame] | 108 | |
Marc Jones | f962aa5 | 2017-03-22 18:47:49 +0800 | [diff] [blame] | 109 | #define LPC_IO_OR_MEM_DECODE_ENABLE 0x48 |
Marshall Dawson | c1f3233 | 2017-04-21 13:54:08 -0600 | [diff] [blame] | 110 | #define LPC_WIDEIO2_ENABLE BIT(25) |
| 111 | #define LPC_WIDEIO1_ENABLE BIT(24) |
| 112 | #define LPC_WIDEIO0_ENABLE BIT(2) |
Marc Jones | f962aa5 | 2017-03-22 18:47:49 +0800 | [diff] [blame] | 113 | |
| 114 | #define LPC_WIDEIO_GENERIC_PORT 0x64 |
| 115 | |
| 116 | #define LPC_ALT_WIDEIO_RANGE_ENABLE 0x74 |
| 117 | #define LPC_ALT_WIDEIO2_ENABLE BIT(3) |
| 118 | #define LPC_ALT_WIDEIO1_ENABLE BIT(2) |
| 119 | #define LPC_ALT_WIDEIO0_ENABLE BIT(0) |
| 120 | |
| 121 | #define LPC_WIDEIO2_GENERIC_PORT 0x90 |
| 122 | |
Elyes HAOUAS | b0f1988 | 2018-06-09 11:59:00 +0200 | [diff] [blame] | 123 | #define SPI_CNTRL0 0x00 |
Marshall Dawson | c1f3233 | 2017-04-21 13:54:08 -0600 | [diff] [blame] | 124 | #define SPI_READ_MODE_MASK (BIT(30) | BIT(29) | BIT(18)) |
Marshall Dawson | 7b0b9f0 | 2017-01-29 17:29:46 -0700 | [diff] [blame] | 125 | /* Nominal is 16.7MHz on older devices, 33MHz on newer */ |
Marshall Dawson | c1f3233 | 2017-04-21 13:54:08 -0600 | [diff] [blame] | 126 | #define SPI_READ_MODE_NOM 0x00000000 |
| 127 | #define SPI_READ_MODE_DUAL112 ( BIT(29) ) |
| 128 | #define SPI_READ_MODE_QUAD114 ( BIT(29) | BIT(18)) |
| 129 | #define SPI_READ_MODE_DUAL122 (BIT(30) ) |
| 130 | #define SPI_READ_MODE_QUAD144 (BIT(30) | BIT(18)) |
| 131 | #define SPI_READ_MODE_NORMAL66 (BIT(30) | BIT(29) ) |
Marshall Dawson | 7b0b9f0 | 2017-01-29 17:29:46 -0700 | [diff] [blame] | 132 | /* Nominal and SPI_READ_MODE_FAST_HUDSON1 are the only valid choices for H1 */ |
Marshall Dawson | c1f3233 | 2017-04-21 13:54:08 -0600 | [diff] [blame] | 133 | #define SPI_READ_MODE_FAST_HUDSON1 ( BIT(18)) |
| 134 | #define SPI_READ_MODE_FAST (BIT(30) | BIT(29) | BIT(18)) |
| 135 | #define SPI_ARB_ENABLE BIT(19) |
Marshall Dawson | 7b0b9f0 | 2017-01-29 17:29:46 -0700 | [diff] [blame] | 136 | |
Marshall Dawson | c1f3233 | 2017-04-21 13:54:08 -0600 | [diff] [blame] | 137 | #define SPI_CNTRL1 0x0c |
Marshall Dawson | 7b0b9f0 | 2017-01-29 17:29:46 -0700 | [diff] [blame] | 138 | /* Use SPI_SPEED_16M-SPI_SPEED_66M below for hudson and bolton */ |
Elyes HAOUAS | b0f1988 | 2018-06-09 11:59:00 +0200 | [diff] [blame] | 139 | #define SPI_CNTRL1_SPEED_MASK (BIT(15) | BIT(14) | BIT(13) | BIT(12)) |
Marshall Dawson | c1f3233 | 2017-04-21 13:54:08 -0600 | [diff] [blame] | 140 | #define SPI_NORM_SPEED_SH 12 |
| 141 | #define SPI_FAST_SPEED_SH 8 |
Marshall Dawson | 7b0b9f0 | 2017-01-29 17:29:46 -0700 | [diff] [blame] | 142 | |
Marshall Dawson | c1f3233 | 2017-04-21 13:54:08 -0600 | [diff] [blame] | 143 | #define SPI100_ENABLE 0x20 |
| 144 | #define SPI_USE_SPI100 BIT(0) |
Marshall Dawson | 7b0b9f0 | 2017-01-29 17:29:46 -0700 | [diff] [blame] | 145 | |
Marshall Dawson | c1f3233 | 2017-04-21 13:54:08 -0600 | [diff] [blame] | 146 | #define SPI100_SPEED_CONFIG 0x22 |
| 147 | #define SPI_SPEED_66M (0x0) |
| 148 | #define SPI_SPEED_33M ( BIT(0)) |
| 149 | #define SPI_SPEED_22M ( BIT(1) ) |
| 150 | #define SPI_SPEED_16M ( BIT(1) | BIT(0)) |
| 151 | #define SPI_SPEED_100M (BIT(2) ) |
| 152 | #define SPI_SPEED_800K (BIT(2) | BIT(0)) |
| 153 | #define SPI_NORM_SPEED_NEW_SH 12 |
| 154 | #define SPI_FAST_SPEED_NEW_SH 8 |
Elyes HAOUAS | b0f1988 | 2018-06-09 11:59:00 +0200 | [diff] [blame] | 155 | #define SPI_ALT_SPEED_NEW_SH 4 |
Marshall Dawson | c1f3233 | 2017-04-21 13:54:08 -0600 | [diff] [blame] | 156 | #define SPI_TPM_SPEED_NEW_SH 0 |
Marshall Dawson | 7b0b9f0 | 2017-01-29 17:29:46 -0700 | [diff] [blame] | 157 | |
Elyes HAOUAS | b0f1988 | 2018-06-09 11:59:00 +0200 | [diff] [blame] | 158 | #define SPI100_HOST_PREF_CONFIG 0x2c |
Marshall Dawson | c1f3233 | 2017-04-21 13:54:08 -0600 | [diff] [blame] | 159 | #define SPI_RD4DW_EN_HOST BIT(15) |
Marshall Dawson | 7b0b9f0 | 2017-01-29 17:29:46 -0700 | [diff] [blame] | 160 | |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 161 | static inline int hudson_sata_enable(void) |
| 162 | { |
| 163 | /* True if IDE or AHCI. */ |
| 164 | return (CONFIG_HUDSON_SATA_MODE == 0) || (CONFIG_HUDSON_SATA_MODE == 2); |
| 165 | } |
| 166 | |
| 167 | static inline int hudson_ide_enable(void) |
| 168 | { |
| 169 | /* True if IDE or LEGACY IDE. */ |
| 170 | return (CONFIG_HUDSON_SATA_MODE == 0) || (CONFIG_HUDSON_SATA_MODE == 3); |
| 171 | } |
| 172 | |
| 173 | #ifndef __SMM__ |
| 174 | |
| 175 | void pm_write8(u8 reg, u8 value); |
| 176 | u8 pm_read8(u8 reg); |
| 177 | void pm_write16(u8 reg, u16 value); |
| 178 | u16 pm_read16(u16 reg); |
| 179 | |
| 180 | #ifdef __PRE_RAM__ |
| 181 | void hudson_lpc_port80(void); |
Dave Frodin | f364fc7 | 2015-03-13 08:22:17 -0600 | [diff] [blame] | 182 | void hudson_lpc_decode(void); |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 183 | void hudson_pci_port80(void); |
| 184 | void hudson_clk_output_48Mhz(void); |
Marshall Dawson | 91dea4a | 2017-02-10 16:03:54 -0700 | [diff] [blame] | 185 | void hudson_read_mode(u32 mode); |
| 186 | void hudson_set_spi100(u16 norm, u16 fast, u16 alt, u16 tpm); |
| 187 | void hudson_disable_4dw_burst(void); |
| 188 | void hudson_set_readspeed(u16 norm, u16 fast); |
Marc Jones | f962aa5 | 2017-03-22 18:47:49 +0800 | [diff] [blame] | 189 | void lpc_wideio_512_window(uint16_t base); |
| 190 | void lpc_wideio_16_window(uint16_t base); |
Marc Jones | 6fcaaef | 2017-04-20 16:48:42 -0600 | [diff] [blame] | 191 | void hudson_tpm_decode_spi(void); |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 192 | int s3_save_nvram_early(u32 dword, int size, int nvram_pos); |
| 193 | int s3_load_nvram_early(int size, u32 *old_dword, int nvram_pos); |
Zheng Bao | 2286138 | 2015-11-21 12:19:22 +0800 | [diff] [blame] | 194 | #if IS_ENABLED(CONFIG_HUDSON_UART) |
| 195 | void configure_hudson_uart(void); |
| 196 | #endif |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 197 | |
| 198 | #else |
Elyes HAOUAS | d9ef546 | 2018-05-19 17:08:23 +0200 | [diff] [blame] | 199 | void hudson_enable(struct device *dev); |
Kyösti Mälkki | e8b4da2 | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 200 | void s3_resume_init_data(void *FchParams); |
| 201 | |
| 202 | #endif /* __PRE_RAM__ */ |
| 203 | #endif /* __SMM__ */ |
| 204 | |
| 205 | #endif /* HUDSON_H */ |