Felix Held | 25aa560 | 2021-12-15 20:52:10 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <amdblocks/agesawrapper.h> |
| 4 | #include <device/device.h> |
| 5 | #include <soc/pci_devs.h> |
| 6 | |
| 7 | static int is_sata_config(void) |
| 8 | { |
| 9 | return !((SataNativeIde == CONFIG_STONEYRIDGE_SATA_MODE) |
| 10 | || (SataLegacyIde == CONFIG_STONEYRIDGE_SATA_MODE)); |
| 11 | } |
| 12 | |
| 13 | static inline int sb_sata_enable(void) |
| 14 | { |
| 15 | /* True if IDE or AHCI. */ |
| 16 | return (SataNativeIde == CONFIG_STONEYRIDGE_SATA_MODE) || |
| 17 | (SataAhci == CONFIG_STONEYRIDGE_SATA_MODE); |
| 18 | } |
| 19 | |
| 20 | static inline int sb_ide_enable(void) |
| 21 | { |
| 22 | /* True if IDE or LEGACY IDE. */ |
| 23 | return (SataNativeIde == CONFIG_STONEYRIDGE_SATA_MODE) || |
| 24 | (SataLegacyIde == CONFIG_STONEYRIDGE_SATA_MODE); |
| 25 | } |
| 26 | |
| 27 | void SetFchResetParams(FCH_RESET_INTERFACE *params) |
| 28 | { |
Felix Held | 25aa560 | 2021-12-15 20:52:10 +0100 | [diff] [blame] | 29 | params->Xhci0Enable = CONFIG(STONEYRIDGE_XHCI_ENABLE); |
Felix Held | 727ee667 | 2023-12-20 22:47:03 +0100 | [diff] [blame] | 30 | if (is_dev_enabled(DEV_PTR(sata))) { |
Felix Held | 25aa560 | 2021-12-15 20:52:10 +0100 | [diff] [blame] | 31 | params->SataEnable = sb_sata_enable(); |
| 32 | params->IdeEnable = sb_ide_enable(); |
| 33 | } else { |
| 34 | params->SataEnable = FALSE; |
| 35 | params->IdeEnable = FALSE; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | void SetFchEnvParams(FCH_INTERFACE *params) |
| 40 | { |
Felix Held | 25aa560 | 2021-12-15 20:52:10 +0100 | [diff] [blame] | 41 | params->AzaliaController = AzEnable; |
| 42 | params->SataClass = CONFIG_STONEYRIDGE_SATA_MODE; |
Felix Held | 727ee667 | 2023-12-20 22:47:03 +0100 | [diff] [blame] | 43 | if (is_dev_enabled(DEV_PTR(sata))) { |
Felix Held | 25aa560 | 2021-12-15 20:52:10 +0100 | [diff] [blame] | 44 | params->SataEnable = is_sata_config(); |
| 45 | params->IdeEnable = !params->SataEnable; |
| 46 | params->SataIdeMode = (CONFIG_STONEYRIDGE_SATA_MODE == |
| 47 | SataLegacyIde); |
| 48 | } else { |
| 49 | params->SataEnable = FALSE; |
| 50 | params->IdeEnable = FALSE; |
| 51 | params->SataIdeMode = FALSE; |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | void SetFchMidParams(FCH_INTERFACE *params) |
| 56 | { |
| 57 | SetFchEnvParams(params); |
| 58 | } |