diff options
author | Angel Pons <th3fanbus@gmail.com> | 2021-01-26 11:11:13 +0100 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2021-02-01 08:54:45 +0000 |
commit | 42e4433ce0d7145ecaa67f413d5ac288f6eb2053 (patch) | |
tree | 9f57e183fc893309d08df15477dc7abceeb6b681 /src/drivers/generic/bayhub | |
parent | 0b7446a2694ef8ad8c480602a7aee9ad90810ac7 (diff) |
bayhub bh720: Add helpers to access PCR registers
The BH720 PCR registers are accessed using an index/data register pair.
Introduce some helper functions to clarify the PCR register operations.
Change-Id: I1a48b10071af20dca61b7dd90c5a70bc9d1089b4
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/49925
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-by: EricR Lai <ericr_lai@compal.corp-partner.google.com>
Diffstat (limited to 'src/drivers/generic/bayhub')
-rw-r--r-- | src/drivers/generic/bayhub/bh720.c | 56 |
1 files changed, 26 insertions, 30 deletions
diff --git a/src/drivers/generic/bayhub/bh720.c b/src/drivers/generic/bayhub/bh720.c index 40788cd31d..58a50173dd 100644 --- a/src/drivers/generic/bayhub/bh720.c +++ b/src/drivers/generic/bayhub/bh720.c @@ -12,49 +12,45 @@ #include "chip.h" #include "bh720.h" -static void bh720_program_hs200_mode(struct device *dev) +static u32 bh720_read_pcr(u32 sdbar, u32 addr) +{ + write32((void *)(sdbar + BH720_MEM_RW_ADR), BH720_MEM_RW_READ | addr); + return read32((void *)(sdbar + BH720_MEM_RW_DATA)); +} + +static void bh720_write_pcr(u32 sdbar, u32 addr, u32 data) +{ + write32((void *)(sdbar + BH720_MEM_RW_DATA), data); + write32((void *)(sdbar + BH720_MEM_RW_ADR), BH720_MEM_RW_WRITE | addr); +} + +static void bh720_rmw_pcr(u32 sdbar, u32 addr, u32 clear, u32 set) { - u32 sdbar; - u32 bh720_pcr_data; + u32 data = bh720_read_pcr(sdbar, addr); + data &= ~clear; + data |= set; + bh720_write_pcr(sdbar, addr, data); +} - sdbar = pci_read_config32(dev, PCI_BASE_ADDRESS_1); +static void bh720_program_hs200_mode(struct device *dev) +{ + u32 sdbar = pci_read_config32(dev, PCI_BASE_ADDRESS_1); /* Enable Memory Access Function */ write32((void *)(sdbar + BH720_MEM_ACCESS_EN), 0x40000000); - write32((void *)(sdbar + BH720_MEM_RW_DATA), 0x80000000); - write32((void *)(sdbar + BH720_MEM_RW_ADR), 0x800000D0); + bh720_write_pcr(sdbar, 0xd0, 0x80000000); /* Set EMMC VCCQ 1.8V PCR 0x308[4] */ - write32((void *)(sdbar + BH720_MEM_RW_ADR), - BH720_MEM_RW_READ | BH720_PCR_EMMC_SETTING); - bh720_pcr_data = read32((void *)(sdbar + BH720_MEM_RW_DATA)); - write32((void *)(sdbar + BH720_MEM_RW_DATA), - bh720_pcr_data | BH720_PCR_EMMC_SETTING_1_8V); - write32((void *)(sdbar + BH720_MEM_RW_ADR), - BH720_MEM_RW_WRITE | BH720_PCR_EMMC_SETTING); + bh720_rmw_pcr(sdbar, BH720_PCR_EMMC_SETTING, 0, BH720_PCR_EMMC_SETTING_1_8V); /* Set Base clock to 200MHz(PCR 0x304[31:16] = 0x2510) */ - write32((void *)(sdbar + BH720_MEM_RW_ADR), - BH720_MEM_RW_READ | BH720_PCR_DrvStrength_PLL); - bh720_pcr_data = read32((void *)(sdbar + BH720_MEM_RW_DATA)); - bh720_pcr_data &= 0x0000FFFF; - bh720_pcr_data |= 0x2510 << 16; - write32((void *)(sdbar + BH720_MEM_RW_DATA), bh720_pcr_data); - write32((void *)(sdbar + BH720_MEM_RW_ADR), - BH720_MEM_RW_WRITE | BH720_PCR_DrvStrength_PLL); + bh720_rmw_pcr(sdbar, BH720_PCR_DrvStrength_PLL, 0xffff << 16, 0x2510 << 16); /* Use PLL Base clock PCR 0x3E4[22] = 1 */ - write32((void *)(sdbar + BH720_MEM_RW_ADR), - BH720_MEM_RW_READ | BH720_PCR_CSR); - bh720_pcr_data = read32((void *)(sdbar + BH720_MEM_RW_DATA)); - write32((void *)(sdbar + BH720_MEM_RW_DATA), - bh720_pcr_data | BH720_PCR_CSR_EMMC_MODE_SEL); - write32((void *)(sdbar + BH720_MEM_RW_ADR), - BH720_MEM_RW_WRITE | BH720_PCR_CSR); + bh720_rmw_pcr(sdbar, BH720_PCR_CSR, 0, BH720_PCR_CSR_EMMC_MODE_SEL); /* Disable Memory Access */ - write32((void *)(sdbar + BH720_MEM_RW_DATA), 0x80000001); - write32((void *)(sdbar + BH720_MEM_RW_ADR), 0x800000D0); + bh720_write_pcr(sdbar, 0xd0, 0x80000001); write32((void *)(sdbar + BH720_MEM_ACCESS_EN), 0x80000000); } |