Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 May 2019 06:06:42 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r348228 - head/sys/dev/amdgpio
Message-ID:  <201905240606.x4O66gqw042365@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Fri May 24 06:06:42 2019
New Revision: 348228
URL: https://svnweb.freebsd.org/changeset/base/348228

Log:
  amdgpio: fix reading status of input pins
  
  AMD FCH GPIO controller uses different bits for setting the output level
  and for reporting the input level.
  
  MFC after:	2 weeks

Modified:
  head/sys/dev/amdgpio/amdgpio.c

Modified: head/sys/dev/amdgpio/amdgpio.c
==============================================================================
--- head/sys/dev/amdgpio/amdgpio.c	Fri May 24 06:02:51 2019	(r348227)
+++ head/sys/dev/amdgpio/amdgpio.c	Fri May 24 06:06:42 2019	(r348228)
@@ -264,10 +264,17 @@ amdgpio_pin_get(device_t dev, uint32_t pin, unsigned i
 	reg = AMDGPIO_PIN_REGISTER(pin);
 	val = amdgpio_read_4(sc, reg);
 
-	if (val & BIT(OUTPUT_VALUE_OFF))
-		*value = GPIO_PIN_HIGH;
-	else
-		*value = GPIO_PIN_LOW;
+	if ((sc->sc_gpio_pins[pin].gp_flags & GPIO_PIN_OUTPUT) != 0) {
+		if (val & BIT(OUTPUT_VALUE_OFF))
+			*value = GPIO_PIN_HIGH;
+		else
+			*value = GPIO_PIN_LOW;
+	} else {
+		if (val & BIT(PIN_STS_OFF))
+			*value = GPIO_PIN_HIGH;
+		else
+			*value = GPIO_PIN_LOW;
+	}
 
 	dprintf("pin %d value 0x%x\n", pin, *value);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905240606.x4O66gqw042365>