summaryrefslogtreecommitdiff
path: root/src/mainboard/pcengines/apu1/gpio_ftns.c
blob: 2c2eb9f7bd06fa6a91cff922716818ef0368ee45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* SPDX-License-Identifier: GPL-2.0-only */

#include <stdint.h>
#include <amdblocks/acpimmio_legacy_gpio100.h>
#include <southbridge/amd/cimx/sb800/SBPLATFORM.h>
#include "gpio_ftns.h"

void configure_gpio(u8 gpio, u8 iomux_ftn, u8 setting)
{
	u8 bdata;

	iomux_write8(gpio, iomux_ftn);

	bdata = gpio_100_read8(gpio);
	bdata &= 0x07;
	bdata |= setting; /* set direction and data value */
	gpio_100_write8(gpio, bdata);
}

u8 read_gpio(u8 gpio)
{
	return (gpio_100_read8(gpio) & GPIO_DATA_IN) ? 1 : 0;
}

int get_spd_offset(void)
{
	u8 spd_offset = read_gpio(GPIO_16);
	return spd_offset;
}