Ronald G. Minnich (rminnich(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2266
-gerrit
commit e912829aa3a74deb0a912d9f806619c12ae3d926
Author: David Hendricks <dhendrix(a)chromium.org>
Date: Sat Feb 2 17:02:36 2013 -0800
exynos/s5p: Add helper function for reading a single MVL3 GPIO
This adds a helper function to read only a single GPIO which uses
3-state logic. Examples of this typically include board straps which
are used to provide mainboard-specific information at the hardware-
level, such as board revision or configuration options.
This is part of a larger clean-up effort for Snow. We may want to
genericise this for other CPUs in the future.
Change-Id: Ic44f5e589cda89b419a07eca246847e9ce7dcd8d
Signed-off-by: David Hendricks <dhendrix(a)chromium.org>
---
src/cpu/samsung/exynos5250/gpio.h | 9 +++++
src/cpu/samsung/s5p-common/s5p_gpio.c | 70 ++++++++++++++++++++++-------------
2 files changed, 54 insertions(+), 25 deletions(-)
diff --git a/src/cpu/samsung/exynos5250/gpio.h b/src/cpu/samsung/exynos5250/gpio.h
index 7606262..1214384 100644
--- a/src/cpu/samsung/exynos5250/gpio.h
+++ b/src/cpu/samsung/exynos5250/gpio.h
@@ -477,6 +477,15 @@ void gpio_set_rate(int gpio, int mode);
*/
int gpio_decode_number(unsigned gpio_list[], int count);
+/*
+ * similar to gpio_decode_number, but reads only a single GPIO
+ *
+ * @param gpio GPIO to read
+ * @return -1 if the value cannot be determined. Otherwise returns
+ * the corresponding MVL3 enum value.
+ */
+int gpio_read_mvl3(unsigned gpio);
+
void gpio_info(void);
#endif /* EXYNOS5250_GPIO_H_ */
diff --git a/src/cpu/samsung/s5p-common/s5p_gpio.c b/src/cpu/samsung/s5p-common/s5p_gpio.c
index 50c4519..f09d0a4 100644
--- a/src/cpu/samsung/s5p-common/s5p_gpio.c
+++ b/src/cpu/samsung/s5p-common/s5p_gpio.c
@@ -21,6 +21,7 @@
/* FIXME(dhendrix): fix this up so it doesn't require a bunch of #ifdefs... */
#include <common.h>
//#include <arch/io.h>
+#include <gpio.h>
#include <arch/gpio.h>
#include <console/console.h>
#include <cpu/samsung/s5p-common/gpio.h>
@@ -414,42 +415,61 @@ int gpio_set_value(unsigned gpio, int value)
*/
#define GPIO_DELAY_US 5
-/* FIXME(dhendrix): this should probably go to a more generic location */
+int gpio_read_mvl3(unsigned gpio)
+{
+ int high, low;
+ enum mvl3 value;
+
+ if (gpio >= GPIO_MAX_PORT)
+ return -1;
+
+ gpio_direction_input(gpio);
+ gpio_set_pull(gpio, EXYNOS_GPIO_PULL_UP);
+ udelay(GPIO_DELAY_US);
+ high = gpio_get_value(gpio);
+ gpio_set_pull(gpio, EXYNOS_GPIO_PULL_DOWN);
+ udelay(GPIO_DELAY_US);
+ low = gpio_get_value(gpio);
+
+ if (high && low) /* external pullup */
+ value = LOGIC_1;
+ else if (!high && !low) /* external pulldown */
+ value = LOGIC_0;
+ else /* floating */
+ value = LOGIC_Z;
+
+ /*
+ * Check if line is externally pulled high and
+ * configure the internal pullup to match. For
+ * floating and pulldowns, the GPIO is already
+ * configured with an internal pulldown from the
+ * above test.
+ */
+ if (value == LOGIC_1)
+ gpio_set_pull(gpio, EXYNOS_GPIO_PULL_UP);
+
+ return value;
+}
+
int gpio_decode_number(unsigned gpio_list[], int count)
{
int result = 0;
int multiplier = 1;
- int value, high, low;
- int gpio, i;
+ int gpio, i, value;
+ enum mvl3 mvl3;
for (i = 0; i < count; i++) {
gpio = gpio_list[i];
- if (gpio >= GPIO_MAX_PORT)
- return -1;
- gpio_direction_input(gpio);
- gpio_set_pull(gpio, EXYNOS_GPIO_PULL_UP);
- udelay(GPIO_DELAY_US);
- high = gpio_get_value(gpio);
- gpio_set_pull(gpio, EXYNOS_GPIO_PULL_DOWN);
- udelay(GPIO_DELAY_US);
- low = gpio_get_value(gpio);
- if (high && low) /* external pullup */
+ mvl3 = gpio_read_mvl3(gpio);
+ if (mvl3 == LOGIC_1)
value = 2;
- else if (!high && !low) /* external pulldown */
+ else if (mvl3 == LOGIC_0)
value = 1;
- else /* floating */
+ else if (mvl3 == LOGIC_Z)
value = 0;
-
- /*
- * Check if line is externally pulled high and
- * configure the internal pullup to match. For
- * floating and pulldowns, the GPIO is already
- * configured with an internal pulldown from the
- * above test.
- */
- if (value == 2)
- gpio_set_pull(gpio, EXYNOS_GPIO_PULL_UP);
+ else
+ return -1;
result += value * multiplier;
multiplier *= 3;
the following patch was just integrated into master:
commit d58ba2add4b0ae955126ca746db39aa9fa98fd9f
Author: David Hendricks <dhendrix(a)chromium.org>
Date: Sat Feb 2 16:57:11 2013 -0800
add gpio.h for generic GPIO-related definitions
This adds /src/include/gpio.h which currently contains generic GPIO
enums for type (in/out/alt) and 3-state logic.
The header was originally written for another FOSS project
(code.google.com/p/mosys) and thus the BSD license.
Change-Id: Id1dff69169e8b1ec372107737d356b0fa0d80498
Signed-off-by: David Hendricks <dhendrix(a)chromium.org>
Reviewed-on: http://review.coreboot.org/2265
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich(a)gmail.com>
Build-Tested: build bot (Jenkins) at Mon Feb 4 05:32:34 2013, giving +1
Reviewed-By: Ronald G. Minnich <rminnich(a)gmail.com> at Mon Feb 4 05:38:32 2013, giving +2
See http://review.coreboot.org/2265 for details.
-gerrit
David Hendricks (dhendrix(a)chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2266
-gerrit
commit 748a6ce14de0f79448b83d2f472acde106183e63
Author: David Hendricks <dhendrix(a)chromium.org>
Date: Sat Feb 2 17:02:36 2013 -0800
exynos/s5p: Add helper function for reading a single MVL3 GPIO
This adds a helper function to read only a single GPIO which uses
3-state logic. Examples of this typically include board straps which
are used to provide mainboard-specific information at the hardware-
level, such as board revision or configuration options.
This is part of a larger clean-up effort for Snow. We may want to
genericise this for other CPUs in the future.
Change-Id: Ic44f5e589cda89b419a07eca246847e9ce7dcd8d
Signed-off-by: David Hendricks <dhendrix(a)chromium.org>
---
src/cpu/samsung/exynos5250/gpio.h | 9 +++++
src/cpu/samsung/s5p-common/s5p_gpio.c | 70 ++++++++++++++++++++++-------------
2 files changed, 54 insertions(+), 25 deletions(-)
diff --git a/src/cpu/samsung/exynos5250/gpio.h b/src/cpu/samsung/exynos5250/gpio.h
index 7606262..1214384 100644
--- a/src/cpu/samsung/exynos5250/gpio.h
+++ b/src/cpu/samsung/exynos5250/gpio.h
@@ -477,6 +477,15 @@ void gpio_set_rate(int gpio, int mode);
*/
int gpio_decode_number(unsigned gpio_list[], int count);
+/*
+ * similar to gpio_decode_number, but reads only a single GPIO
+ *
+ * @param gpio GPIO to read
+ * @return -1 if the value cannot be determined. Otherwise returns
+ * the corresponding MVL3 enum value.
+ */
+int gpio_read_mvl3(unsigned gpio);
+
void gpio_info(void);
#endif /* EXYNOS5250_GPIO_H_ */
diff --git a/src/cpu/samsung/s5p-common/s5p_gpio.c b/src/cpu/samsung/s5p-common/s5p_gpio.c
index 50c4519..f09d0a4 100644
--- a/src/cpu/samsung/s5p-common/s5p_gpio.c
+++ b/src/cpu/samsung/s5p-common/s5p_gpio.c
@@ -21,6 +21,7 @@
/* FIXME(dhendrix): fix this up so it doesn't require a bunch of #ifdefs... */
#include <common.h>
//#include <arch/io.h>
+#include <gpio.h>
#include <arch/gpio.h>
#include <console/console.h>
#include <cpu/samsung/s5p-common/gpio.h>
@@ -414,42 +415,61 @@ int gpio_set_value(unsigned gpio, int value)
*/
#define GPIO_DELAY_US 5
-/* FIXME(dhendrix): this should probably go to a more generic location */
+int gpio_read_mvl3(unsigned gpio)
+{
+ int high, low;
+ enum mvl3 value;
+
+ if (gpio >= GPIO_MAX_PORT)
+ return -1;
+
+ gpio_direction_input(gpio);
+ gpio_set_pull(gpio, EXYNOS_GPIO_PULL_UP);
+ udelay(GPIO_DELAY_US);
+ high = gpio_get_value(gpio);
+ gpio_set_pull(gpio, EXYNOS_GPIO_PULL_DOWN);
+ udelay(GPIO_DELAY_US);
+ low = gpio_get_value(gpio);
+
+ if (high && low) /* external pullup */
+ value = LOGIC_1;
+ else if (!high && !low) /* external pulldown */
+ value = LOGIC_0;
+ else /* floating */
+ value = LOGIC_Z;
+
+ /*
+ * Check if line is externally pulled high and
+ * configure the internal pullup to match. For
+ * floating and pulldowns, the GPIO is already
+ * configured with an internal pulldown from the
+ * above test.
+ */
+ if (value == LOGIC_1)
+ gpio_set_pull(gpio, EXYNOS_GPIO_PULL_UP);
+
+ return value;
+}
+
int gpio_decode_number(unsigned gpio_list[], int count)
{
int result = 0;
int multiplier = 1;
- int value, high, low;
- int gpio, i;
+ int gpio, i, value;
+ enum mvl3 mvl3;
for (i = 0; i < count; i++) {
gpio = gpio_list[i];
- if (gpio >= GPIO_MAX_PORT)
- return -1;
- gpio_direction_input(gpio);
- gpio_set_pull(gpio, EXYNOS_GPIO_PULL_UP);
- udelay(GPIO_DELAY_US);
- high = gpio_get_value(gpio);
- gpio_set_pull(gpio, EXYNOS_GPIO_PULL_DOWN);
- udelay(GPIO_DELAY_US);
- low = gpio_get_value(gpio);
- if (high && low) /* external pullup */
+ mvl3 = gpio_read_mvl3(gpio);
+ if (mvl3 == LOGIC_1)
value = 2;
- else if (!high && !low) /* external pulldown */
+ else if (mvl3 == LOGIC_0)
value = 1;
- else /* floating */
+ else if (mvl3 == LOGIC_Z)
value = 0;
-
- /*
- * Check if line is externally pulled high and
- * configure the internal pullup to match. For
- * floating and pulldowns, the GPIO is already
- * configured with an internal pulldown from the
- * above test.
- */
- if (value == 2)
- gpio_set_pull(gpio, EXYNOS_GPIO_PULL_UP);
+ else
+ return -1;
result += value * multiplier;
multiplier *= 3;
David Hendricks (dhendrix(a)chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2265
-gerrit
commit 65c920db029e8c09f1e071627c92eb54fd67ee32
Author: David Hendricks <dhendrix(a)chromium.org>
Date: Sat Feb 2 16:57:11 2013 -0800
add gpio.h for generic GPIO-related definitions
This adds /src/include/gpio.h which currently contains generic GPIO
enums for type (in/out/alt) and 3-state logic.
The header was originally written for another FOSS project
(code.google.com/p/mosys) and thus the BSD license.
Change-Id: Id1dff69169e8b1ec372107737d356b0fa0d80498
Signed-off-by: David Hendricks <dhendrix(a)chromium.org>
---
src/include/gpio.h | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/src/include/gpio.h b/src/include/gpio.h
new file mode 100644
index 0000000..f602b1e
--- /dev/null
+++ b/src/include/gpio.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2012, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef GPIO_H
+#define GPIO_H
+
+enum gpio_types {
+ GPIO_IN,
+ GPIO_OUT,
+ GPIO_ALT, /* catch-all for alternate functions */
+};
+
+/*
+ * Many-value logic (3 states). This can be used for inputs whereby presence
+ * of external pull-up or pull-down resistors can be added to overcome internal
+ * pull-ups/pull-downs and force a single value.
+ *
+ * Thus, external pull resistors can force a 0 or 1 and if the value changes
+ * along with internal pull-up/down enable then the input is floating.
+ *
+ * Vpd | Vpu | MVL
+ * -----------------
+ * 0 | 0 | 0
+ * -----------------
+ * 0 | 1 | Z <-- floating input will follow internal pull up/down
+ * -----------------
+ * 1 | 1 | 1
+ */
+enum mvl3 {
+ LOGIC_0,
+ LOGIC_1,
+ LOGIC_Z, /* high impedence / tri-stated / floating */
+};
+
+#endif /* GPIO_H */
David Hendricks (dhendrix(a)chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2265
-gerrit
commit 3de55ceee7b39e99105216cc913efcf327aab60d
Author: David Hendricks <dhendrix(a)chromium.org>
Date: Sat Feb 2 16:57:11 2013 -0800
add gpio.h for generic GPIO-related definitions
This adds /src/include/gpio.h which currently contains generic GPIO
enums for type (in/out/alt) and 3-state logic.
The header was originally written for another FOSS project
(code.google.com/p/mosys) and thus the BSD license.
Change-Id: Id1dff69169e8b1ec372107737d356b0fa0d80498
Signed-off-by: David Hendricks <dhendrix(a)chromium.org>
---
src/include/gpio.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/src/include/gpio.h b/src/include/gpio.h
new file mode 100644
index 0000000..8ef6e02
--- /dev/null
+++ b/src/include/gpio.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2012, Google Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef GPIO_H
+#define GPIO_H
+
+enum gpio_types {
+ GPIO_IN,
+ GPIO_OUT,
+ GPIO_ALT, /* catch-all for alternate functions */
+};
+
+/*
+ * Many-value logic (3 states). This can be used for inputs whereby presence
+ * of external pull-up or pull-down resistors can be added to overcome internal
+ * pull-ups/pull-downs and force a single value.
+ *
+ * Thus, external pull resistors can force a 0 or 1 and if the value changes
+ * along with internal pull-up/down enable then the input is floating.
+ *
+ * Vpd | Vpu | MVL
+ * -----------------
+ * 0 | 0 | 0
+ * -----------------
+ * 0 | 1 | Z <-- floating input will follow internal pull up/down
+ * -----------------
+ * 1 | 1 | 1
+ */
+enum mvl3 {
+ LOGIC_0,
+ LOGIC_1,
+ LOGIC_Z, /* high impedence / tri-stated / floating */
+};
+
+#endif /* GPIO_H */
David Hendricks (dhendrix(a)chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2269
-gerrit
commit 70d59ee5d1679c104df56bd8af28fe7696500d44
Author: David Hendricks <dhendrix(a)chromium.org>
Date: Sun Feb 3 18:50:37 2013 -0800
exynos5250: make lowlevel_init_c.c benign
This file has mostly (but not entirely) been replaced by coreboot
stage files. We'll keep it around for a bit longer as a reference,
but in the meantime we'll stop compiling it as to avoid comptilation
issues as we change other parts of the code.
Change-Id: I669fb1e5a1517f35979590957d581bd33df53d29
Signed-off-by: David Hendricks <dhendrix(a)chromium.org>
---
src/cpu/samsung/exynos5250/Makefile.inc | 3 ---
src/cpu/samsung/exynos5250/lowlevel_init_c.c | 6 ++++++
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/cpu/samsung/exynos5250/Makefile.inc b/src/cpu/samsung/exynos5250/Makefile.inc
index 6eee503..49285e7 100644
--- a/src/cpu/samsung/exynos5250/Makefile.inc
+++ b/src/cpu/samsung/exynos5250/Makefile.inc
@@ -6,7 +6,6 @@
romstage-y += clock.c
romstage-y += clock_init.c
romstage-y += exynos_cache.c
-romstage-y += lowlevel_init_c.c
romstage-y += pinmux.c
romstage-y += power.c
romstage-y += soc.c
@@ -23,7 +22,6 @@ romstage-y += dmc_init_ddr3.c
ramstage-y += clock.c
ramstage-y += clock_init.c
ramstage-y += exynos_cache.c
-ramstage-y += lowlevel_init_c.c
ramstage-y += pinmux.c
ramstage-y += power.c
ramstage-y += soc.c
@@ -31,7 +29,6 @@ ramstage-y += uart.c
#ramstage-$(CONFIG_EXYNOS_ACE_SHA) += ace_sha.c
#ramstage-$(CONFIG_SATA_AHCI) += sata.c
-ramstage-$(CONFIG_SPL_BUILD) += lowlevel_init_c.c
exynos5250_add_bl1: $(obj)/coreboot.pre
printf " DD Adding Samsung Exynos5250 BL1\n"
diff --git a/src/cpu/samsung/exynos5250/lowlevel_init_c.c b/src/cpu/samsung/exynos5250/lowlevel_init_c.c
index 848ebee..daa691f 100644
--- a/src/cpu/samsung/exynos5250/lowlevel_init_c.c
+++ b/src/cpu/samsung/exynos5250/lowlevel_init_c.c
@@ -23,6 +23,12 @@
* MA 02111-1307 USA
*/
+/*
+ * FIXME: This file is essentially the "bootblock" leftover from U-Boot. For
+ * now it serves as a reference until all the resume-related stuff is added
+ * to the appropriate bootblock/romstage/ramstage files in coreboot.
+ */
+
#include <common.h>
#include <config.h>
#include <cpu/samsung/exynos5-common/exynos5-common.h>
David Hendricks (dhendrix(a)chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2266
-gerrit
commit 94c3b0a80f06d974a2b3eadaa31b5340dc43601a
Author: David Hendricks <dhendrix(a)chromium.org>
Date: Sat Feb 2 17:02:36 2013 -0800
exynos/s5p: Add helper function for reading a single MVL3 GPIO
This adds a helper function to read only a single GPIO which uses
3-state logic. Examples of this typically include board straps which
are used to provide mainboard-specific information at the hardware-
level, such as board revision or configuration options.
This is part of a larger clean-up effort for Snow. We may want to
genericise this for other CPUs in the future.
Change-Id: Ic44f5e589cda89b419a07eca246847e9ce7dcd8d
Signed-off-by: David Hendricks <dhendrix(a)chromium.org>
---
src/cpu/samsung/exynos5250/gpio.h | 9 +++++
src/cpu/samsung/s5p-common/s5p_gpio.c | 69 ++++++++++++++++++++++-------------
2 files changed, 53 insertions(+), 25 deletions(-)
diff --git a/src/cpu/samsung/exynos5250/gpio.h b/src/cpu/samsung/exynos5250/gpio.h
index 7606262..1214384 100644
--- a/src/cpu/samsung/exynos5250/gpio.h
+++ b/src/cpu/samsung/exynos5250/gpio.h
@@ -477,6 +477,15 @@ void gpio_set_rate(int gpio, int mode);
*/
int gpio_decode_number(unsigned gpio_list[], int count);
+/*
+ * similar to gpio_decode_number, but reads only a single GPIO
+ *
+ * @param gpio GPIO to read
+ * @return -1 if the value cannot be determined. Otherwise returns
+ * the corresponding MVL3 enum value.
+ */
+int gpio_read_mvl3(unsigned gpio);
+
void gpio_info(void);
#endif /* EXYNOS5250_GPIO_H_ */
diff --git a/src/cpu/samsung/s5p-common/s5p_gpio.c b/src/cpu/samsung/s5p-common/s5p_gpio.c
index 50c4519..8332015 100644
--- a/src/cpu/samsung/s5p-common/s5p_gpio.c
+++ b/src/cpu/samsung/s5p-common/s5p_gpio.c
@@ -414,42 +414,61 @@ int gpio_set_value(unsigned gpio, int value)
*/
#define GPIO_DELAY_US 5
-/* FIXME(dhendrix): this should probably go to a more generic location */
+int gpio_read_mvl3(unsigned gpio)
+{
+ int high, low;
+ enum mvl3 value;
+
+ if (gpio >= GPIO_MAX_PORT)
+ return -1;
+
+ gpio_direction_input(gpio);
+ gpio_set_pull(gpio, EXYNOS_GPIO_PULL_UP);
+ udelay(GPIO_DELAY_US);
+ high = gpio_get_value(gpio);
+ gpio_set_pull(gpio, EXYNOS_GPIO_PULL_DOWN);
+ udelay(GPIO_DELAY_US);
+ low = gpio_get_value(gpio);
+
+ if (high && low) /* external pullup */
+ value = LOGIC_1;
+ else if (!high && !low) /* external pulldown */
+ value = LOGIC_0;
+ else /* floating */
+ value = LOGIC_Z;
+
+ /*
+ * Check if line is externally pulled high and
+ * configure the internal pullup to match. For
+ * floating and pulldowns, the GPIO is already
+ * configured with an internal pulldown from the
+ * above test.
+ */
+ if (value == LOGIC_1)
+ gpio_set_pull(gpio, EXYNOS_GPIO_PULL_UP);
+
+ return value;
+}
+
int gpio_decode_number(unsigned gpio_list[], int count)
{
int result = 0;
int multiplier = 1;
- int value, high, low;
- int gpio, i;
+ int gpio, i, value;
+ enum mvl3 mvl3;
for (i = 0; i < count; i++) {
gpio = gpio_list[i];
- if (gpio >= GPIO_MAX_PORT)
- return -1;
- gpio_direction_input(gpio);
- gpio_set_pull(gpio, EXYNOS_GPIO_PULL_UP);
- udelay(GPIO_DELAY_US);
- high = gpio_get_value(gpio);
- gpio_set_pull(gpio, EXYNOS_GPIO_PULL_DOWN);
- udelay(GPIO_DELAY_US);
- low = gpio_get_value(gpio);
- if (high && low) /* external pullup */
+ mvl3 = gpio_read_mvl3(gpio);
+ if (mvl3 == LOGIC_1)
value = 2;
- else if (!high && !low) /* external pulldown */
+ else if (mvl3 == LOGIC_0)
value = 1;
- else /* floating */
+ else if (mvl3 == LOGIC_Z)
value = 0;
-
- /*
- * Check if line is externally pulled high and
- * configure the internal pullup to match. For
- * floating and pulldowns, the GPIO is already
- * configured with an internal pulldown from the
- * above test.
- */
- if (value == 2)
- gpio_set_pull(gpio, EXYNOS_GPIO_PULL_UP);
+ else
+ return -1;
result += value * multiplier;
multiplier *= 3;
David Hendricks (dhendrix(a)chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2265
-gerrit
commit 92c06f391765b44805d647e7e437f57c7952b7de
Author: David Hendricks <dhendrix(a)chromium.org>
Date: Sat Feb 2 16:57:11 2013 -0800
add gpio.h for generic GPIO-related definitions
This adds /src/include/gpio.h which currently contains generic GPIO
enums for type (in/out/alt) and 3-state logic.
The header was originally written for another FOSS project (mosys)
and thus the BSD license.
Change-Id: Id1dff69169e8b1ec372107737d356b0fa0d80498
Signed-off-by: David Hendricks <dhendrix(a)chromium.org>
---
src/include/gpio.h | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/src/include/gpio.h b/src/include/gpio.h
new file mode 100644
index 0000000..f602b1e
--- /dev/null
+++ b/src/include/gpio.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2012, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef GPIO_H
+#define GPIO_H
+
+enum gpio_types {
+ GPIO_IN,
+ GPIO_OUT,
+ GPIO_ALT, /* catch-all for alternate functions */
+};
+
+/*
+ * Many-value logic (3 states). This can be used for inputs whereby presence
+ * of external pull-up or pull-down resistors can be added to overcome internal
+ * pull-ups/pull-downs and force a single value.
+ *
+ * Thus, external pull resistors can force a 0 or 1 and if the value changes
+ * along with internal pull-up/down enable then the input is floating.
+ *
+ * Vpd | Vpu | MVL
+ * -----------------
+ * 0 | 0 | 0
+ * -----------------
+ * 0 | 1 | Z <-- floating input will follow internal pull up/down
+ * -----------------
+ * 1 | 1 | 1
+ */
+enum mvl3 {
+ LOGIC_0,
+ LOGIC_1,
+ LOGIC_Z, /* high impedence / tri-stated / floating */
+};
+
+#endif /* GPIO_H */