Zheng Bao (zheng.bao(a)amd.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11732
-gerrit
commit e1404e338a49a4bd28a2e428d8a5c9cac7346017
Author: zbao <fishbaozi(a)gmail.com>
Date: Fri Nov 6 16:19:16 2015 +0800
AMD/Bettong: add function to read board version
Bettong uses 3 GPIO(5-7) pins to identify board.
The GPIO ports are mapped to MMIO space.
The GPIO value and board version are mapped as follow:
GPIO5 GPIO6 GPIO7 Version
0 0 0 A
0 0 1 B
......
1 1 1 H
Change-Id: I72df28043057d8c4ccc4a2e645011ca5379e9928
Signed-off-by: WANG Siyuan <wangsiyuanbuaa(a)gmail.com>
Signed-off-by: WANG Siyuan <SiYuan.Wang(a)amd.com>
Signed-off-by: Zheng Bao <fishbaozi(a)gmail.com>
---
src/mainboard/amd/bettong/Makefile.inc | 2 ++
src/mainboard/amd/bettong/boardid.c | 56 ++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+)
diff --git a/src/mainboard/amd/bettong/Makefile.inc b/src/mainboard/amd/bettong/Makefile.inc
index 0361362..5358d92 100644
--- a/src/mainboard/amd/bettong/Makefile.inc
+++ b/src/mainboard/amd/bettong/Makefile.inc
@@ -15,9 +15,11 @@
romstage-y += BiosCallOuts.c
romstage-y += PlatformGnbPcie.c
+romstage-y += boardid.c
ramstage-y += BiosCallOuts.c
ramstage-y += PlatformGnbPcie.c
ifeq ($(CONFIG_HUDSON_IMC_FWM), y)
ramstage-y += fchec.c
endif
+ramstage-y += boardid.c
diff --git a/src/mainboard/amd/bettong/boardid.c b/src/mainboard/amd/bettong/boardid.c
new file mode 100644
index 0000000..3cb40bc
--- /dev/null
+++ b/src/mainboard/amd/bettong/boardid.c
@@ -0,0 +1,56 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2015 Advanced Micro Devices, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc.
+ */
+
+#include <stdint.h>
+#include <arch/io.h>
+#include <arch/acpi.h>
+#include <console/console.h>
+#include <reset.h>
+#include <boardid.h>
+
+/**
+ *Bettong uses 3 GPIO(5-7) pins to identify board.
+ *The GPIO ports are mapped to MMIO space.
+ *The GPIO value and board version are mapped as follow:
+ *GPIO5 GPIO6 GPIO7 Version
+ * 0 0 0 A
+ * 0 0 1 B
+ * ......
+ * 1 1 1 H
+ */
+
+uint8_t board_id(void)
+{
+ u32 gpiommioaddr;
+ u8 value = 0;
+ u8 boardrev = 0;
+ char boardid;
+
+ gpiommioaddr = 0xfed80000ul + 0x1500;
+ value = *(volatile u8 *) (gpiommioaddr + (7 << 2) + 2); //agpio7 //board_id2
+ boardrev = value & 1;
+ value = *(volatile u8 *) (gpiommioaddr + (6 << 2) + 2); //agpio6 //board_id1
+ boardrev |= (value & 1) << 1;
+ value = *(volatile u8 *) (gpiommioaddr + (5 << 2) + 2); //agpio5 //board_id0
+ boardrev |= (value & 1) << 2;
+
+ boardid = 'A' + boardrev;
+
+ return boardid;
+}
Werner Zeh (werner.zeh(a)siemens.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/12341
-gerrit
commit 155b1fc6035a067d6b7b73ec792bec22ad5da509
Author: Werner Zeh <werner.zeh(a)siemens.com>
Date: Fri Nov 6 08:38:38 2015 +0100
fsp_baytrail: Add functions to set a GPIO
Add two functions to set a memory mapped GPIO to a given value.
TEST=Booted siemens/mc_tcu3 board and confirmed GPIO-value after
using this functions.
Change-Id: Idc14c5d4049487e60040cc294ba0cea363d998a6
Signed-off-by: Werner Zeh <werner.zeh(a)siemens.com>
---
src/soc/intel/fsp_baytrail/baytrail/gpio.h | 18 ++++++++++++++++++
src/soc/intel/fsp_baytrail/gpio.c | 24 ++++++++++++++++++++++++
2 files changed, 42 insertions(+)
diff --git a/src/soc/intel/fsp_baytrail/baytrail/gpio.h b/src/soc/intel/fsp_baytrail/baytrail/gpio.h
index 15f65ee..3d30a86 100644
--- a/src/soc/intel/fsp_baytrail/baytrail/gpio.h
+++ b/src/soc/intel/fsp_baytrail/baytrail/gpio.h
@@ -336,7 +336,9 @@ void setup_soc_gpios(struct soc_gpio_config *config);
/* This function is weak and can be overridden by a mainboard function. */
struct soc_gpio_config* mainboard_get_gpios(void);
uint8_t read_score_gpio(uint8_t gpio_num);
+void write_score_gpio(uint8_t gpio_num, uint8_t val);
uint8_t read_ssus_gpio(uint8_t gpio_num);
+void write_ssus_gpio(uint8_t gpio_num, uint8_t val);
void configure_ssus_gpio(uint8_t gpio_num, uint32_t pconf0, uint32_t pad_val);
void configure_score_gpio(uint8_t gpio_num, uint32_t pconf0, uint32_t pad_val);
@@ -398,6 +400,22 @@ static inline int ssus_get_gpio(int pad)
return read32(val_addr) & PAD_VAL_HIGH;
}
+/* These functions require that the output pad is configured as an output */
+/* GPIO and is mapped to memory space and not IO space. */
+static inline void score_set_gpio(int pad, int val)
+{
+ uint32_t *val_addr = score_pconf0(pad) + (PAD_VAL_REG/sizeof(uint32_t));
+
+ write32(val_addr, ((read32(val_addr) & ~0x1) | val));
+}
+
+static inline void ssus_set_gpio(int pad, int val)
+{
+ uint32_t *val_addr = ssus_pconf0(pad) + (PAD_VAL_REG/sizeof(uint32_t));
+
+ write32(val_addr, ((read32(val_addr) & ~0x1) | val));
+}
+
static inline void ssus_disable_internal_pull(int pad)
{
const uint32_t pull_mask = ~(0xf << 7);
diff --git a/src/soc/intel/fsp_baytrail/gpio.c b/src/soc/intel/fsp_baytrail/gpio.c
index 6313596..3497a63 100644
--- a/src/soc/intel/fsp_baytrail/gpio.c
+++ b/src/soc/intel/fsp_baytrail/gpio.c
@@ -266,6 +266,18 @@ uint8_t read_score_gpio(uint8_t gpio_num)
return retval;
}
+/** \brief sets an output SCORE GPIO to desired value
+ *
+ * @param gpio_num The GPIO number being read
+ * @param val The value this output must be set to (0 or 1)
+ * @return void
+ */
+void write_score_gpio(uint8_t gpio_num, uint8_t val)
+{
+ if (gpio_num < GPSCORE_COUNT)
+ score_set_gpio(gpscore_gpio_to_pad[gpio_num], val);
+}
+
/** \brief returns the input / output value from an SSUS GPIO
*
* @param gpio_num The GPIO number being read
@@ -280,6 +292,18 @@ uint8_t read_ssus_gpio(uint8_t gpio_num)
return retval;
}
+/** \brief sets an output SSUS GPIO to desired value
+ *
+ * @param gpio_num The GPIO number being read
+ * @param val The value this output must be set to (0 or 1)
+ * @return void
+ */
+void write_ssus_gpio(uint8_t gpio_num, uint8_t val)
+{
+ if (gpio_num < GPSSUS_COUNT)
+ ssus_set_gpio(gpssus_gpio_to_pad[gpio_num], val);
+}
+
/** \brief Sets up the function, pulls, and Input/Output of a Baytrail
* SSUS (S5) or SCORE (S0) GPIO
*
Werner Zeh (werner.zeh(a)siemens.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/12341
-gerrit
commit 856d6b3aed589550a3164a1ac0b3459abd2c9a30
Author: Werner Zeh <werner.zeh(a)siemens.com>
Date: Fri Nov 6 08:38:38 2015 +0100
fsp_baytrail: Add functions to set a GPIO
Add two functions to set a memory mapped GPIO to a given value.
TEST=siemens/mc_tcu3 booted and GPIO-value confirmed after
using this functions.
Change-Id: Idc14c5d4049487e60040cc294ba0cea363d998a6
Signed-off-by: Werner Zeh <werner.zeh(a)siemens.com>
---
src/soc/intel/fsp_baytrail/baytrail/gpio.h | 16 ++++++++++++++++
src/soc/intel/fsp_baytrail/gpio.c | 24 ++++++++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/src/soc/intel/fsp_baytrail/baytrail/gpio.h b/src/soc/intel/fsp_baytrail/baytrail/gpio.h
index 15f65ee..70981b4 100644
--- a/src/soc/intel/fsp_baytrail/baytrail/gpio.h
+++ b/src/soc/intel/fsp_baytrail/baytrail/gpio.h
@@ -398,6 +398,22 @@ static inline int ssus_get_gpio(int pad)
return read32(val_addr) & PAD_VAL_HIGH;
}
+/* These functions require that the output pad is configured as an output */
+/* GPIO and is mapped to memory space and not IO space. */
+static inline void score_set_gpio(int pad, int val)
+{
+ uint32_t *val_addr = score_pconf0(pad) + (PAD_VAL_REG/sizeof(uint32_t));
+
+ write32(val_addr, ((read32(val_addr) & ~0x1) | val));
+}
+
+static inline void ssus_set_gpio(int pad, int val)
+{
+ uint32_t *val_addr = ssus_pconf0(pad) + (PAD_VAL_REG/sizeof(uint32_t));
+
+ write32(val_addr, ((read32(val_addr) & ~0x1) | val));
+}
+
static inline void ssus_disable_internal_pull(int pad)
{
const uint32_t pull_mask = ~(0xf << 7);
diff --git a/src/soc/intel/fsp_baytrail/gpio.c b/src/soc/intel/fsp_baytrail/gpio.c
index 6313596..3497a63 100644
--- a/src/soc/intel/fsp_baytrail/gpio.c
+++ b/src/soc/intel/fsp_baytrail/gpio.c
@@ -266,6 +266,18 @@ uint8_t read_score_gpio(uint8_t gpio_num)
return retval;
}
+/** \brief sets an output SCORE GPIO to desired value
+ *
+ * @param gpio_num The GPIO number being read
+ * @param val The value this output must be set to (0 or 1)
+ * @return void
+ */
+void write_score_gpio(uint8_t gpio_num, uint8_t val)
+{
+ if (gpio_num < GPSCORE_COUNT)
+ score_set_gpio(gpscore_gpio_to_pad[gpio_num], val);
+}
+
/** \brief returns the input / output value from an SSUS GPIO
*
* @param gpio_num The GPIO number being read
@@ -280,6 +292,18 @@ uint8_t read_ssus_gpio(uint8_t gpio_num)
return retval;
}
+/** \brief sets an output SSUS GPIO to desired value
+ *
+ * @param gpio_num The GPIO number being read
+ * @param val The value this output must be set to (0 or 1)
+ * @return void
+ */
+void write_ssus_gpio(uint8_t gpio_num, uint8_t val)
+{
+ if (gpio_num < GPSSUS_COUNT)
+ ssus_set_gpio(gpssus_gpio_to_pad[gpio_num], val);
+}
+
/** \brief Sets up the function, pulls, and Input/Output of a Baytrail
* SSUS (S5) or SCORE (S0) GPIO
*