aboutsummaryrefslogtreecommitdiff
path: root/src/soc/amd/stoneyridge/gpio.c
diff options
context:
space:
mode:
authorMarshall Dawson <marshalldawson3rd@gmail.com>2019-05-01 17:48:44 -0600
committerMartin Roth <martinroth@google.com>2019-05-08 13:50:04 +0000
commit976e3e9ae68d64c374e7e2ace2df86173bd5bec8 (patch)
tree16db838d9cc3733ccc91b1e928a650d98877d9d7 /src/soc/amd/stoneyridge/gpio.c
parentb4b9efcfdd47efe67b13e1cf8cfea2ffe08fb012 (diff)
soc/amd/stoneyridge: Add iomux read/write functions
Add functions to read and write the region in the AcpiMmio block. Convert gpio.c to use them instead of creating pointers. Change-Id: I2a0f44b6ec7261648cf0357b44a6c18dd40d1504 Signed-off-by: Marshall Dawson <marshalldawson3rd@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/32647 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin Roth <martinroth@google.com>
Diffstat (limited to 'src/soc/amd/stoneyridge/gpio.c')
-rw-r--r--src/soc/amd/stoneyridge/gpio.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/soc/amd/stoneyridge/gpio.c b/src/soc/amd/stoneyridge/gpio.c
index b747538eaa..285fedd238 100644
--- a/src/soc/amd/stoneyridge/gpio.c
+++ b/src/soc/amd/stoneyridge/gpio.c
@@ -221,7 +221,6 @@ uint16_t gpio_acpi_pin(gpio_t gpio)
void sb_program_gpios(const struct soc_amd_gpio *gpio_list_ptr, size_t size)
{
- uint8_t *mux_ptr;
uint32_t *gpio_ptr, *inter_master;
uint32_t control, control_flags, edge_level, direction;
uint32_t mask, bit_edge, bit_level;
@@ -252,9 +251,8 @@ void sb_program_gpios(const struct soc_amd_gpio *gpio_list_ptr, size_t size)
control = gpio_list_ptr[index].control;
control_flags = gpio_list_ptr[index].flags;
- mux_ptr = (uint8_t *)(uintptr_t)(gpio + ACPIMMIO_IOMUX_BASE);
- write8(mux_ptr, mux & AMD_GPIO_MUX_MASK);
- read8(mux_ptr); /* Flush posted write */
+ iomux_write8(gpio, mux & AMD_GPIO_MUX_MASK);
+ iomux_read8(gpio); /* Flush posted write */
/* special case if pin 2 is assigned to wake */
if ((gpio == 2) && !(mux & AMD_GPIO_MUX_MASK))
route_sci(GPIO_2_EVENT);
@@ -348,11 +346,9 @@ static void save_i2c_pin_registers(uint8_t gpio,
struct soc_amd_i2c_save *save_table)
{
uint32_t *gpio_ptr;
- uint8_t *mux_ptr;
- mux_ptr = (uint8_t *)(uintptr_t)(gpio + ACPIMMIO_IOMUX_BASE);
gpio_ptr = (uint32_t *)gpio_get_address(gpio);
- save_table->mux_value = read8(mux_ptr);
+ save_table->mux_value = iomux_read8(gpio);
save_table->control_value = read32(gpio_ptr);
}
@@ -360,12 +356,10 @@ static void restore_i2c_pin_registers(uint8_t gpio,
struct soc_amd_i2c_save *save_table)
{
uint32_t *gpio_ptr;
- uint8_t *mux_ptr;
- mux_ptr = (uint8_t *)(uintptr_t)(gpio + ACPIMMIO_IOMUX_BASE);
gpio_ptr = (uint32_t *)gpio_get_address(gpio);
- write8(mux_ptr, save_table->mux_value);
- read8(mux_ptr);
+ iomux_write8(gpio, save_table->mux_value);
+ iomux_read8(gpio);
write32(gpio_ptr, save_table->control_value);
read32(gpio_ptr);
}