Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/1049
-gerrit
commit 3a99e2cd0443e017d6978930db98ad579af5a93f
Author: Vadim Bendebury <vbendeb(a)chromium.org>
Date: Tue May 15 14:18:59 2012 -0700
Provide functions to access arbitrary GPIO pins and vectors
This change adds utility functions which allow to read any GPIO pin,
as well as a vector of GPIO pin values.
As presented, these functions will be available to Sandy Bridge and
Ivy Bridge systems only.
There is no error checking: trying to read GPIO pin number which
exceeds actual number of pins will return zero, trying to read GPIO
which is not actually configured as such will return unpredictable
value.
When reading a GPIO pin vector, the pin numbers are passed in an
array, terminated by -1. For instance, to read GPIO pins 4, 2, 15 as a
three bit number GPIO4 * 4 + GPIO2 * 2 + GPIO15 * 1, one should pass
pointer to array of {4, 2, 15, -1}.
Change-Id: I042c12dbcb3c46d14ed864a48fc37d54355ced7d
Signed-off-by: Vadim Bendebury <vbendeb(a)chromium.org>
---
src/southbridge/intel/bd82x6x/gpio.c | 37 ++++++++++++++++++++++++++++++++++
src/southbridge/intel/bd82x6x/gpio.h | 8 +++++++
2 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/src/southbridge/intel/bd82x6x/gpio.c b/src/southbridge/intel/bd82x6x/gpio.c
index 598726a..2ba34ea 100644
--- a/src/southbridge/intel/bd82x6x/gpio.c
+++ b/src/southbridge/intel/bd82x6x/gpio.c
@@ -25,6 +25,8 @@
#include "pch.h"
#include "gpio.h"
+#define MAX_GPIO_NUMBER 75 /* zero based */
+
void setup_pch_gpios(const struct pch_gpio_map *gpio)
{
u16 gpiobase = pci_read_config16(PCH_LPC_DEV, GPIO_BASE) & 0xfffc;
@@ -63,3 +65,38 @@ void setup_pch_gpios(const struct pch_gpio_map *gpio)
if (gpio->set3.reset)
outl(*((u32*)gpio->set3.reset), gpiobase + GP_RST_SEL3);
}
+
+int get_gpio(int gpio_num)
+{
+ static const int gpio_reg_offsets[] = {0xc, 0x38, 0x48};
+ u16 gpio_base = pci_read_config16(PCH_LPC_DEV, GPIO_BASE) & 0xfffc;
+ int index, bit;
+
+ if (gpio_num > MAX_GPIO_NUMBER)
+ return 0; /* Just ignore wrong gpio numbers. */
+
+ index = gpio_num / 32;
+ bit = gpio_num % 32;
+
+ return (inl(gpio_base + gpio_reg_offsets[index]) >> bit) & 1;
+}
+
+/*
+ * get a number comprised of multiple GPIO values. gpio_num_array points to
+ * the array of gpio pin numbers to scan, terminated by -1.
+ */
+unsigned get_gpios(const int *gpio_num_array)
+{
+ int gpio;
+ unsigned bitmask = 1;
+ unsigned vector = 0;
+
+ while (bitmask &&
+ ((gpio = *gpio_num_array++) != -1)) {
+ vector <<= 1;
+ if (get_gpio(gpio))
+ vector |= bitmask;
+ bitmask <<= 1;
+ }
+ return vector;
+}
diff --git a/src/southbridge/intel/bd82x6x/gpio.h b/src/southbridge/intel/bd82x6x/gpio.h
index 214947f..44e808a 100644
--- a/src/southbridge/intel/bd82x6x/gpio.h
+++ b/src/southbridge/intel/bd82x6x/gpio.h
@@ -150,4 +150,12 @@ struct pch_gpio_map {
/* Configure GPIOs with mainboard provided settings */
void setup_pch_gpios(const struct pch_gpio_map *gpio);
+/* get GPIO pin value */
+int get_gpio(int gpio_num);
+/*
+ * get a number comprised of multiple GPIO values. gpio_num_array points to
+ * the array of gpio pin numbers to scan, terminated by -1.
+ */
+unsigned get_gpios(const int *gpio_num_array);
+
#endif
Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/1051
-gerrit
commit 63acdad535f94580b137661a97a99264c5d00541
Author: Stefan Reinauer <reinauer(a)chromium.org>
Date: Wed May 23 14:16:47 2012 -0700
Sandybridge: Remove remnants of FDT support from MRC cache code
Originally, ChromeBooks would get the offset of the MRC cache
from an entry in the u-boot device tree. Not everyone wants to
use u-boot on Sandybridge systems, however.
Since the new code (based on Kconfig) is now fully working, we
can drop the u-boot device tree remnants.
Change-Id: I4e012ea981f16dce9a4d155254facd29874b28ef
Signed-off-by: Stefan Reinauer <reinauer(a)google.com>
---
src/northbridge/intel/sandybridge/mrccache.c | 80 ++++----------------------
1 files changed, 11 insertions(+), 69 deletions(-)
diff --git a/src/northbridge/intel/sandybridge/mrccache.c b/src/northbridge/intel/sandybridge/mrccache.c
index aad2b91..d774ff0 100644
--- a/src/northbridge/intel/sandybridge/mrccache.c
+++ b/src/northbridge/intel/sandybridge/mrccache.c
@@ -28,19 +28,6 @@
#include "sandybridge.h"
#include <spi.h>
#include <spi_flash.h>
-/* Using the FDT FMAP for finding the MRC cache area requires including FDT
- * support in coreboot, which we would like to avoid. There are a number of
- * options:
- * - Have each mainboard Kconfig supply a hard-coded offset
- * - For ChromeOS devices: implement native FMAP
- * - For non-ChromeOS devices: use CBFS
- * For now let's leave this code in here until the issue is sorted out in
- * a way that works for everyone.
- */
-#undef USE_FDT_FMAP_FOR_MRC_CACHE
-#ifdef USE_FDT_FMAP_FOR_MRC_CACHE
-#include <fdt/libfdt.h>
-#endif
struct mrc_data_container *next_mrc_block(struct mrc_data_container *mrc_cache)
{
@@ -61,64 +48,19 @@ int is_mrc_cache(struct mrc_data_container *mrc_cache)
return (!!mrc_cache) && (mrc_cache->mrc_signature == MRC_DATA_SIGNATURE);
}
+/* Right now, the offsets for the MRC cache area are hard-coded in the
+ * northbridge Kconfig. In order to make this more flexible, there are
+ * a number of options:
+ * - Have each mainboard Kconfig supply a hard-coded offset
+ * - For ChromeOS devices: implement native FMAP
+ * - For non-ChromeOS devices: use CBFS
+ */
u32 get_mrc_cache_region(struct mrc_data_container **mrc_region_ptr)
{
- u8 *mrc_region;
- u32 region_size;
-#ifdef USE_FDT_FMAP_FOR_MRC_CACHE
- u32 *data;
- const struct fdt_header *fdt_header;
- const struct fdt_property *fdtp;
- int offset, len;
- const char *compatible = "chromeos,flashmap";
- const char *subnode = "rw-mrc-cache";
- const char *property = "reg";
- u64 flashrom_base = 0;
-
- fdt_header = cbfs_find_file(CONFIG_FDT_FILE_NAME, CBFS_TYPE_FDT);
-
- if (!fdt_header) {
- printk(BIOS_ERR, "%s: no FDT found!\n", __func__);
- return 0;
- }
-
- offset = fdt_node_offset_by_compatible(fdt_header, 0, compatible);
- if (offset < 0) {
- printk(BIOS_ERR, "%s: no %s node found!\n",
- __func__, compatible);
- return 0;
- }
-
- if (fdt_get_base_addr(fdt_header, offset, &flashrom_base) < 0) {
- printk(BIOS_ERR, "%s: no base address in node name!\n",
- __func__);
- return 0;
- }
-
- offset = fdt_subnode_offset(fdt_header, offset, subnode);
- if (offset < 0) {
- printk(BIOS_ERR, "%s: no %s found!\n", __func__, subnode);
- return 0;
- }
-
- fdtp = fdt_get_property(fdt_header, offset, property, &len);
- if (!fdtp || (len != 8)) {
- printk(BIOS_ERR, "%s: property %s at %p, len %d!\n",
- __func__, property, fdtp, len);
- return 0;
- }
-
- data = (u32 *)fdtp->data;
-
- // Calculate actual address of the MRC cache in memory
- region_size = fdt32_to_cpu(data[1]);
- mrc_region = (u8*)((unsigned long)flashrom_base + fdt32_to_cpu(data[0]));
-#else
- region_size = CONFIG_MRC_CACHE_SIZE;
- mrc_region = (u8*)(CONFIG_MRC_CACHE_BASE + CONFIG_MRC_CACHE_LOCATION);
-#endif
- *mrc_region_ptr = (struct mrc_data_container *)mrc_region;
+ u32 region_size = CONFIG_MRC_CACHE_SIZE;
+ *mrc_region_ptr = (struct mrc_data_container *)
+ (CONFIG_MRC_CACHE_BASE + CONFIG_MRC_CACHE_LOCATION);
return region_size;
}
@@ -182,7 +124,7 @@ struct mrc_data_container *find_current_mrc_cache(void)
entry_id++;
mrc_cache = mrc_next;
mrc_next = next_mrc_block(mrc_cache);
- /* Stay in the mrcdata region defined in fdt */
+ /* Stay in the mrc data region */
if ((void*)mrc_next >= (void*)(mrc_region + region_size))
break;
}
Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/1042
-gerrit
commit 1d0ab4d60b763fe740e4ae94d0dd4ca692286494
Author: Stefan Reinauer <reinauer(a)chromium.org>
Date: Tue May 15 12:36:57 2012 -0700
Move subsystem IDs to devicetree.cb
A while back coreboot was changed to read the subsystem IDs from
devicetree.cb to allow each onboard PCI device to have its own
subsystem id. When we originally branched, this was not the case,
and the sandybridge/ivybridge mainboards have not been updated yet.
Also, drop the subsystem ID from Emerald Lake 2, since it's not a
Google device.
Change-Id: Ie96fd67cd2ff65ad6ff725914e3bad843e78712e
Signed-off-by: Stefan Reinauer <reinauer(a)google.com>
---
src/mainboard/intel/emeraldlake2/Kconfig | 8 --------
src/mainboard/samsung/lumpy/Kconfig | 8 --------
src/mainboard/samsung/lumpy/devicetree.cb | 1 +
src/mainboard/samsung/stumpy/Kconfig | 8 --------
src/mainboard/samsung/stumpy/devicetree.cb | 1 +
5 files changed, 2 insertions(+), 24 deletions(-)
diff --git a/src/mainboard/intel/emeraldlake2/Kconfig b/src/mainboard/intel/emeraldlake2/Kconfig
index 9e4f347..873d273 100644
--- a/src/mainboard/intel/emeraldlake2/Kconfig
+++ b/src/mainboard/intel/emeraldlake2/Kconfig
@@ -43,12 +43,4 @@ config VGA_BIOS_FILE
string
default "pci8086,0166.rom"
-config MAINBOARD_PCI_SUBSYSTEM_VENDOR_ID
- hex
- default 0x1ae0
-
-config MAINBOARD_PCI_SUBSYSTEM_DEVICE_ID
- hex
- default 0xc000
-
endif # BOARD_INTEL_EMERALDLAKE2
diff --git a/src/mainboard/samsung/lumpy/Kconfig b/src/mainboard/samsung/lumpy/Kconfig
index 200edac..0835012 100644
--- a/src/mainboard/samsung/lumpy/Kconfig
+++ b/src/mainboard/samsung/lumpy/Kconfig
@@ -44,14 +44,6 @@ config VGA_BIOS_FILE
string
default "pci8086,0106.rom"
-config MAINBOARD_PCI_SUBSYSTEM_VENDOR_ID
- hex
- default 0x1ae0
-
-config MAINBOARD_PCI_SUBSYSTEM_DEVICE_ID
- hex
- default 0xc000
-
config MAINBOARD_POWER_ON_AFTER_POWER_FAIL
bool
default n
diff --git a/src/mainboard/samsung/lumpy/devicetree.cb b/src/mainboard/samsung/lumpy/devicetree.cb
index 36af1ca..3e93df4 100644
--- a/src/mainboard/samsung/lumpy/devicetree.cb
+++ b/src/mainboard/samsung/lumpy/devicetree.cb
@@ -33,6 +33,7 @@ chip northbridge/intel/sandybridge
end
device pci_domain 0 on
+ subsystemid 0x1ae0 0xc000 inherit
device pci 00.0 on end # host bridge
device pci 02.0 on end # vga controller
diff --git a/src/mainboard/samsung/stumpy/Kconfig b/src/mainboard/samsung/stumpy/Kconfig
index dda3002..18094cf 100644
--- a/src/mainboard/samsung/stumpy/Kconfig
+++ b/src/mainboard/samsung/stumpy/Kconfig
@@ -43,14 +43,6 @@ config VGA_BIOS_FILE
string
default "pci8086,0106.rom"
-config MAINBOARD_PCI_SUBSYSTEM_VENDOR_ID
- hex
- default 0x1ae0
-
-config MAINBOARD_PCI_SUBSYSTEM_DEVICE_ID
- hex
- default 0xc000
-
config MAINBOARD_POWER_ON_AFTER_POWER_FAIL
bool
default n
diff --git a/src/mainboard/samsung/stumpy/devicetree.cb b/src/mainboard/samsung/stumpy/devicetree.cb
index f10b283..b59dcb2 100644
--- a/src/mainboard/samsung/stumpy/devicetree.cb
+++ b/src/mainboard/samsung/stumpy/devicetree.cb
@@ -28,6 +28,7 @@ chip northbridge/intel/sandybridge
end
device pci_domain 0 on
+ subsystemid 0x1ae0 0xc000 inherit
device pci 00.0 on end # host bridge
device pci 02.0 on end # vga controller
Stefan Reinauer (stefan.reinauer(a)coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/1043
-gerrit
commit ae114e94989a273015a758ffcd4260d88be8050f
Author: Stefan Reinauer <reinauer(a)chromium.org>
Date: Tue May 15 13:28:07 2012 -0700
Implement %zu / %zd in printk
The SPI drivers from u-boot make heavy use of %zu/%zd (size_t/ssize_t).
Implement this in our printk implementation so we get useful output.
Change-Id: I91798ff4f28b9c3cd4db204c7ec503596d247dcd
Signed-off-by: Stefan Reinauer <reinauer(a)google.com>
---
src/console/vtxprintf.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/console/vtxprintf.c b/src/console/vtxprintf.c
index a370e5f..28c5a60 100644
--- a/src/console/vtxprintf.c
+++ b/src/console/vtxprintf.c
@@ -170,7 +170,7 @@ repeat:
/* get the conversion qualifier */
qualifier = -1;
- if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
+ if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt == 'z') {
qualifier = *fmt;
++fmt;
if (*fmt == 'l') {
@@ -218,7 +218,6 @@ repeat:
field_width, precision, flags);
continue;
-
case 'n':
if (qualifier == 'L') {
long long *ip = va_arg(args, long long *);
@@ -265,6 +264,8 @@ repeat:
num = va_arg(args, unsigned long long);
} else if (qualifier == 'l') {
num = va_arg(args, unsigned long);
+ } else if (qualifier == 'z') {
+ num = va_arg(args, size_t);
} else if (qualifier == 'h') {
num = (unsigned short) va_arg(args, int);
if (flags & SIGN)