Kyösti Mälkki has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/37324 )
Change subject: [WIP] soc/amd/common: Access ACPI MMIO via proper symbols ......................................................................
[WIP] soc/amd/common: Access ACPI MMIO via proper symbols
Using proper symbols for base addresses, it is possible to only define the symbols for base addesses implemented in the platform.
TBD: Check for bad aliasing effects when immediate value changes to memory reference.
Change-Id: Ib8599ee93bfb1c2d6d9b4accfca1ebbefe758e09 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- M src/soc/amd/common/block/acpimmio/mmio_util.c M src/soc/amd/common/block/include/amdblocks/acpimmio.h M src/soc/amd/common/block/include/amdblocks/acpimmio_map.h 3 files changed, 125 insertions(+), 73 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/24/37324/1
diff --git a/src/soc/amd/common/block/acpimmio/mmio_util.c b/src/soc/amd/common/block/acpimmio/mmio_util.c index 04d5e4a..51e661d 100644 --- a/src/soc/amd/common/block/acpimmio/mmio_util.c +++ b/src/soc/amd/common/block/acpimmio/mmio_util.c @@ -18,6 +18,28 @@ #include <amdblocks/acpimmio_map.h> #include <amdblocks/acpimmio.h>
+uint8_t *const acpimmio_sm_pci = (void *)ACPIMMIO_SM_PCI_BASE; +uint8_t *const acpimmio_smi = (void *)ACPIMMIO_SMI_BASE; +uint8_t *const acpimmio_pmio = (void *)ACPIMMIO_PMIO_BASE; +uint8_t *const acpimmio_pmio2 = (void *)ACPIMMIO_PMIO2_BASE; +uint8_t *const acpimmio_biosram = (void *)ACPIMMIO_BIOSRAM_BASE; +uint8_t *const acpimmio_cmosram = (void *)ACPIMMIO_CMOSRAM_BASE; +uint8_t *const acpimmio_cmos = (void *)ACPIMMIO_CMOS_BASE; +uint8_t *const acpimmio_acpi = (void *)ACPIMMIO_ACPI_BASE; +uint8_t *const acpimmio_asf = (void *)ACPIMMIO_ASF_BASE; +uint8_t *const acpimmio_smbus = (void *)ACPIMMIO_SMBUS_BASE; +uint8_t *const acpimmio_wdt = (void *)ACPIMMIO_WDT_BASE; +uint8_t *const acpimmio_hpet = (void *)ACPIMMIO_HPET_BASE; +uint8_t *const acpimmio_iomux = (void *)ACPIMMIO_IOMUX_BASE; +uint8_t *const acpimmio_misc = (void *)ACPIMMIO_MISC_BASE; +uint8_t *const acpimmio_dpvga = (void *)ACPIMMIO_DPVGA_BASE; +uint8_t *const acpimmio_gpio0 = (void *)ACPIMMIO_GPIO0_BASE; +uint8_t *const acpimmio_gpio1 = (void *)ACPIMMIO_GPIO1_BASE; +uint8_t *const acpimmio_gpio2 = (void *)ACPIMMIO_GPIO2_BASE; +uint8_t *const acpimmio_xhci_pm = (void *)ACPIMMIO_XHCIPM_BASE; +uint8_t *const acpimmio_acdc_tmr = (void *)ACPIMMIO_ACDCTMR_BASE; +uint8_t *const acpimmio_aoac = (void *)ACPIMMIO_AOAC_BASE; + void enable_acpimmio_decode(void) { uint32_t dw; diff --git a/src/soc/amd/common/block/include/amdblocks/acpimmio.h b/src/soc/amd/common/block/include/amdblocks/acpimmio.h index 57d24db..9df47d1 100644 --- a/src/soc/amd/common/block/include/amdblocks/acpimmio.h +++ b/src/soc/amd/common/block/include/amdblocks/acpimmio.h @@ -121,272 +121,272 @@
static inline uint8_t sm_pci_read8(uint8_t reg) { - return read8((void *)(ACPIMMIO_SM_PCI_BASE + reg)); + return read8(acpimmio_sm_pci + reg); }
static inline uint16_t sm_pci_read16(uint8_t reg) { - return read16((void *)(ACPIMMIO_SM_PCI_BASE + reg)); + return read16(acpimmio_sm_pci + reg); }
static inline uint32_t sm_pci_read32(uint8_t reg) { - return read32((void *)(ACPIMMIO_SM_PCI_BASE + reg)); + return read32(acpimmio_sm_pci + reg); }
static inline void sm_pci_write8(uint8_t reg, uint8_t value) { - write8((void *)(ACPIMMIO_SM_PCI_BASE + reg), value); + write8(acpimmio_sm_pci + reg, value); }
static inline void sm_pci_write16(uint8_t reg, uint16_t value) { - write16((void *)(ACPIMMIO_SM_PCI_BASE + reg), value); + write16(acpimmio_sm_pci + reg, value); }
static inline void sm_pci_write32(uint8_t reg, uint32_t value) { - write32((void *)(ACPIMMIO_SM_PCI_BASE + reg), value); + write32(acpimmio_sm_pci + reg, value); }
static inline uint8_t smi_read8(uint8_t reg) { - return read8((void *)(ACPIMMIO_SMI_BASE + reg)); + return read8(acpimmio_smi + reg); }
static inline uint16_t smi_read16(uint8_t reg) { - return read16((void *)(ACPIMMIO_SMI_BASE + reg)); + return read16(acpimmio_smi + reg); }
static inline uint32_t smi_read32(uint8_t reg) { - return read32((void *)(ACPIMMIO_SMI_BASE + reg)); + return read32(acpimmio_smi + reg); }
static inline void smi_write8(uint8_t reg, uint8_t value) { - write8((void *)(ACPIMMIO_SMI_BASE + reg), value); + write8(acpimmio_smi + reg, value); }
static inline void smi_write16(uint8_t reg, uint16_t value) { - write16((void *)(ACPIMMIO_SMI_BASE + reg), value); + write16(acpimmio_smi + reg, value); }
static inline void smi_write32(uint8_t reg, uint32_t value) { - write32((void *)(ACPIMMIO_SMI_BASE + reg), value); + write32(acpimmio_smi + reg, value); }
static inline uint8_t pm_read8(uint8_t reg) { - return read8((void *)(ACPIMMIO_PMIO_BASE + reg)); + return read8(acpimmio_pmio + reg); }
static inline uint16_t pm_read16(uint8_t reg) { - return read16((void *)(ACPIMMIO_PMIO_BASE + reg)); + return read16(acpimmio_pmio + reg); }
static inline uint32_t pm_read32(uint8_t reg) { - return read32((void *)(ACPIMMIO_PMIO_BASE + reg)); + return read32(acpimmio_pmio + reg); }
static inline void pm_write8(uint8_t reg, uint8_t value) { - write8((void *)(ACPIMMIO_PMIO_BASE + reg), value); + write8(acpimmio_pmio + reg, value); }
static inline void pm_write16(uint8_t reg, uint16_t value) { - write16((void *)(ACPIMMIO_PMIO_BASE + reg), value); + write16(acpimmio_pmio + reg, value); }
static inline void pm_write32(uint8_t reg, uint32_t value) { - write32((void *)(ACPIMMIO_PMIO_BASE + reg), value); + write32(acpimmio_pmio + reg, value); }
static inline uint8_t biosram_read8(uint8_t reg) { - return read8((void *)(ACPIMMIO_BIOSRAM_BASE + reg)); + return read8(acpimmio_biosram + reg); }
static inline void biosram_write8(uint8_t reg, uint8_t value) { - write8((void *)(ACPIMMIO_BIOSRAM_BASE + reg), value); + write8(acpimmio_biosram + reg, value); }
static inline uint8_t acpi_read8(uint8_t reg) { - return read8((void *)(ACPIMMIO_ACPI_BASE + reg)); + return read8(acpimmio_acpi + reg); }
static inline uint16_t acpi_read16(uint8_t reg) { - return read16((void *)(ACPIMMIO_ACPI_BASE + reg)); + return read16(acpimmio_acpi + reg); }
static inline uint32_t acpi_read32(uint8_t reg) { - return read32((void *)(ACPIMMIO_ACPI_BASE + reg)); + return read32(acpimmio_acpi + reg); }
static inline void acpi_write8(uint8_t reg, uint8_t value) { - write8((void *)(ACPIMMIO_ACPI_BASE + reg), value); + write8(acpimmio_acpi + reg, value); }
static inline void acpi_write16(uint8_t reg, uint16_t value) { - write16((void *)(ACPIMMIO_ACPI_BASE + reg), value); + write16(acpimmio_acpi + reg, value); }
static inline void acpi_write32(uint8_t reg, uint32_t value) { - write32((void *)(ACPIMMIO_ACPI_BASE + reg), value); + write32(acpimmio_acpi + reg, value); }
static inline uint8_t asf_read8(uint8_t reg) { - return read8((void *)(ACPIMMIO_ASF_BASE + reg)); + return read8(acpimmio_asf + reg); }
static inline uint16_t asf_read16(uint8_t reg) { - return read16((void *)(ACPIMMIO_ASF_BASE + reg)); + return read16(acpimmio_asf + reg); }
static inline void asf_write8(uint8_t reg, uint8_t value) { - write8((void *)(ACPIMMIO_ASF_BASE + reg), value); + write8(acpimmio_asf + reg, value); }
static inline void asf_write16(uint8_t reg, uint16_t value) { - write16((void *)(ACPIMMIO_ASF_BASE + reg), value); + write16(acpimmio_asf + reg, value); }
static inline uint8_t smbus_read8(uint8_t reg) { - return read8((void *)(ACPIMMIO_SMBUS_BASE + reg)); + return read8(acpimmio_smbus + reg); }
static inline uint16_t smbus_read16(uint8_t reg) { - return read16((void *)(ACPIMMIO_SMBUS_BASE + reg)); + return read16(acpimmio_smbus + reg); }
static inline void smbus_write8(uint8_t reg, uint8_t value) { - write8((void *)(ACPIMMIO_SMBUS_BASE + reg), value); + write8(acpimmio_smbus + reg, value); }
static inline void smbus_write16(uint8_t reg, uint16_t value) { - write16((void *)(ACPIMMIO_SMBUS_BASE + reg), value); + write16(acpimmio_smbus + reg, value); }
static inline uint8_t iomux_read8(uint8_t reg) { - return read8((void *)(ACPIMMIO_IOMUX_BASE + reg)); + return read8(acpimmio_iomux + reg); }
static inline uint16_t iomux_read16(uint8_t reg) { - return read16((void *)(ACPIMMIO_IOMUX_BASE + reg)); + return read16(acpimmio_iomux + reg); }
static inline uint32_t iomux_read32(uint8_t reg) { - return read32((void *)(ACPIMMIO_IOMUX_BASE + reg)); + return read32(acpimmio_iomux + reg); }
static inline void iomux_write8(uint8_t reg, uint8_t value) { - write8((void *)(ACPIMMIO_IOMUX_BASE + reg), value); + write8(acpimmio_iomux + reg, value); }
static inline void iomux_write16(uint8_t reg, uint16_t value) { - write16((void *)(ACPIMMIO_IOMUX_BASE + reg), value); + write16(acpimmio_iomux + reg, value); }
static inline void iomux_write32(uint8_t reg, uint32_t value) { - write32((void *)(ACPIMMIO_IOMUX_BASE + reg), value); + write32(acpimmio_iomux + reg, value); }
static inline uint8_t misc_read8(uint8_t reg) { - return read8((void *)(ACPIMMIO_MISC_BASE + reg)); + return read8(acpimmio_misc + reg); }
static inline uint16_t misc_read16(uint8_t reg) { - return read16((void *)(ACPIMMIO_MISC_BASE + reg)); + return read16(acpimmio_misc + reg); }
static inline uint32_t misc_read32(uint8_t reg) { - return read32((void *)(ACPIMMIO_MISC_BASE + reg)); + return read32(acpimmio_misc + reg); }
static inline void misc_write8(uint8_t reg, uint8_t value) { - write8((void *)(ACPIMMIO_MISC_BASE + reg), value); + write8(acpimmio_misc + reg, value); }
static inline void misc_write16(uint8_t reg, uint16_t value) { - write16((void *)(ACPIMMIO_MISC_BASE + reg), value); + write16(acpimmio_misc + reg, value); }
static inline void misc_write32(uint8_t reg, uint32_t value) { - write32((void *)(ACPIMMIO_MISC_BASE + reg), value); + write32(acpimmio_misc + reg, value); }
static inline uint8_t xhci_pm_read8(uint8_t reg) { - return read8((void *)(ACPIMMIO_XHCIPM_BASE + reg)); + return read8(acpimmio_xhci_pm + reg); }
static inline uint16_t xhci_pm_read16(uint8_t reg) { - return read16((void *)(ACPIMMIO_XHCIPM_BASE + reg)); + return read16(acpimmio_xhci_pm + reg); }
static inline uint32_t xhci_pm_read32(uint8_t reg) { - return read32((void *)(ACPIMMIO_XHCIPM_BASE + reg)); + return read32(acpimmio_xhci_pm + reg); }
static inline void xhci_pm_write8(uint8_t reg, uint8_t value) { - write8((void *)(ACPIMMIO_XHCIPM_BASE + reg), value); + write8(acpimmio_xhci_pm + reg, value); }
static inline void xhci_pm_write16(uint8_t reg, uint16_t value) { - write16((void *)(ACPIMMIO_XHCIPM_BASE + reg), value); + write16(acpimmio_xhci_pm + reg, value); }
static inline void xhci_pm_write32(uint8_t reg, uint32_t value) { - write32((void *)(ACPIMMIO_XHCIPM_BASE + reg), value); + write32(acpimmio_xhci_pm + reg, value); }
static inline uint8_t aoac_read8(uint8_t reg) { - return read8((void *)(ACPIMMIO_AOAC_BASE + reg)); + return read8(acpimmio_aoac + reg); }
static inline void aoac_write8(uint8_t reg, uint8_t value) { - write8((void *)(ACPIMMIO_AOAC_BASE + reg), value); + write8(acpimmio_aoac + reg, value); }
#endif /* __AMDBLOCKS_ACPIMMIO_H__ */ diff --git a/src/soc/amd/common/block/include/amdblocks/acpimmio_map.h b/src/soc/amd/common/block/include/amdblocks/acpimmio_map.h index 755af52..4f64ee6 100644 --- a/src/soc/amd/common/block/include/amdblocks/acpimmio_map.h +++ b/src/soc/amd/common/block/include/amdblocks/acpimmio_map.h @@ -42,26 +42,56 @@ */
#define AMD_SB_ACPI_MMIO_ADDR 0xfed80000 -#define ACPIMMIO_SM_PCI_BASE 0xfed80000 -#define ACPIMMIO_SMI_BASE 0xfed80200 -#define ACPIMMIO_PMIO_BASE 0xfed80300 -#define ACPIMMIO_PMIO2_BASE 0xfed80400 -#define ACPIMMIO_BIOSRAM_BASE 0xfed80500 -#define ACPIMMIO_CMOSRAM_BASE 0xfed80600 -#define ACPIMMIO_CMOS_BASE 0xfed80700 -#define ACPIMMIO_ACPI_BASE 0xfed80800 -#define ACPIMMIO_ASF_BASE 0xfed80900 -#define ACPIMMIO_SMBUS_BASE 0xfed80a00 -#define ACPIMMIO_WDT_BASE 0xfed80b00 -#define ACPIMMIO_HPET_BASE 0xfed80c00 -#define ACPIMMIO_IOMUX_BASE 0xfed80d00 + +#ifndef __ACPI__ +#define ACPIMMIO_SM_PCI_BASE (AMD_SB_ACPI_MMIO_ADDR + 0x0000) +#define ACPIMMIO_SMI_BASE (AMD_SB_ACPI_MMIO_ADDR + 0x0200) +#define ACPIMMIO_PMIO_BASE (AMD_SB_ACPI_MMIO_ADDR + 0x0300) +#define ACPIMMIO_PMIO2_BASE (AMD_SB_ACPI_MMIO_ADDR + 0x0400) +#define ACPIMMIO_BIOSRAM_BASE (AMD_SB_ACPI_MMIO_ADDR + 0x0500) +#define ACPIMMIO_CMOSRAM_BASE (AMD_SB_ACPI_MMIO_ADDR + 0x0600) +#define ACPIMMIO_CMOS_BASE (AMD_SB_ACPI_MMIO_ADDR + 0x0700) +#define ACPIMMIO_ACPI_BASE (AMD_SB_ACPI_MMIO_ADDR + 0x0800) +#define ACPIMMIO_ASF_BASE (AMD_SB_ACPI_MMIO_ADDR + 0x0900) +#define ACPIMMIO_SMBUS_BASE (AMD_SB_ACPI_MMIO_ADDR + 0x0a00) +#define ACPIMMIO_WDT_BASE (AMD_SB_ACPI_MMIO_ADDR + 0x0b00) +#define ACPIMMIO_HPET_BASE (AMD_SB_ACPI_MMIO_ADDR + 0x0c00) +#define ACPIMMIO_IOMUX_BASE (AMD_SB_ACPI_MMIO_ADDR + 0x0d00) +#define ACPIMMIO_MISC_BASE (AMD_SB_ACPI_MMIO_ADDR + 0x0e00) +#define ACPIMMIO_DPVGA_BASE (AMD_SB_ACPI_MMIO_ADDR + 0x1400) +#define ACPIMMIO_GPIO0_BASE (AMD_SB_ACPI_MMIO_ADDR + 0x1500) +#define ACPIMMIO_GPIO1_BASE (AMD_SB_ACPI_MMIO_ADDR + 0x1600) +#define ACPIMMIO_GPIO2_BASE (AMD_SB_ACPI_MMIO_ADDR + 0x1700) +#define ACPIMMIO_XHCIPM_BASE (AMD_SB_ACPI_MMIO_ADDR + 0x1c00) +#define ACPIMMIO_ACDCTMR_BASE (AMD_SB_ACPI_MMIO_ADDR + 0x1d00) +#define ACPIMMIO_AOAC_BASE (AMD_SB_ACPI_MMIO_ADDR + 0x1e00) + +extern uint8_t *const acpimmio_sm_pci; +extern uint8_t *const acpimmio_smi; +extern uint8_t *const acpimmio_pmio; +extern uint8_t *const acpimmio_pmio2; +extern uint8_t *const acpimmio_biosram; +extern uint8_t *const acpimmio_cmosram; +extern uint8_t *const acpimmio_cmos; +extern uint8_t *const acpimmio_acpi; +extern uint8_t *const acpimmio_asf; +extern uint8_t *const acpimmio_smbus; +extern uint8_t *const acpimmio_wdt; +extern uint8_t *const acpimmio_hpet; +extern uint8_t *const acpimmio_iomux; +extern uint8_t *const acpimmio_misc; +extern uint8_t *const acpimmio_dpvga; +extern uint8_t *const acpimmio_gpio0; +extern uint8_t *const acpimmio_gpio1; +extern uint8_t *const acpimmio_gpio2; +extern uint8_t *const acpimmio_xhci_pm; +extern uint8_t *const acpimmio_acdc_tmr; +extern uint8_t *const acpimmio_aoac; +#else + +/* Damn, ASL fails on additions. */ #define ACPIMMIO_MISC_BASE 0xfed80e00 -#define ACPIMMIO_DPVGA_BASE 0xfed81400 #define ACPIMMIO_GPIO0_BASE 0xfed81500 -#define ACPIMMIO_GPIO1_BASE 0xfed81600 -#define ACPIMMIO_GPIO2_BASE 0xfed81700 -#define ACPIMMIO_XHCIPM_BASE 0xfed81c00 -#define ACPIMMIO_ACDCTMR_BASE 0xfed81d00 -#define ACPIMMIO_AOAC_BASE 0xfed81e00 +#endif
#endif /* __AMDBLOCKS_ACPIMMIO_MAP_H__ */