the following patch was just integrated into master:
commit 3f9a62e5ade9bf2461c93ac8c6b52c4bdca09742
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Thu Jun 20 20:25:21 2013 +0300
Add pci_devfn_t and use with __SIMPLE_DEVICE__
Declare the functions that may be used in both romstage and ramstage
with simple device model. This will later allow to define PCI access
functions for ramstage using the inlined functions from romstage.
Change-Id: I32ff622883ceee4628e6b1b01023b970e379113f
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Reviewed-on: http://review.coreboot.org/3508
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin(a)google.com>
See http://review.coreboot.org/3508 for details.
-gerrit
the following patch was just integrated into master:
commit a2adaeb68cdecc2bc1185613a11b7d49915883ec
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Mon Aug 12 00:09:21 2013 +0300
usbdebug: Only test two possible USB device numbers
After an USB device sees USB bus reset on the bus, it will reset to
device number 0. Per the EHCI debug port specification, a debug
dongle device may reset to the fixed debug device number of 127 instead.
Thus there is no need to try device numbers from 1 to 126.
Do a sanity-check on a returned debug descriptor as I experienced
some USB flash memory to respond on this request with zero-fill data.
Change-Id: I78d58f3dc049cd8c20c6e2aa3a4207ad7e6a6d33
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Reviewed-on: http://review.coreboot.org/3861
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin(a)google.com>
See http://review.coreboot.org/3861 for details.
-gerrit
Shawn Nematbakhsh (shawnn(a)chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3883
-gerrit
commit c7f2a52195966f7b7a930e339475ce65a8405b4a
Author: Shawn Nematbakhsh <shawnn(a)chromium.org>
Date: Fri Aug 23 14:12:24 2013 -0700
libpayload: Remove unnecessary keyboard mode setting code
keyboard_init attempts to read the existing mode register, set the
'XLATE' bit, and write it back. The implementation is buggy because the
keyboard may be active at the time we read the mode, and we can
misinterpret scancode data as the reply to our command. It leads to
problems where the KB gets disabled in firmware.
In fact, setting the 'XLATE' bit is completely unnecessary, even if we
desire QEMU keyboard support. We already set this bit when we initialize
the keyboard in pc_keyboard_init. Basically, this code does nothing
(or worse), so just remove it.
Change-Id: Iab23f03fa8bced74842c33a7d263de5f449bb983
Signed-off-by: Shawn Nematbakhsh <shawnn(a)chromium.org>
---
payloads/libpayload/drivers/keyboard.c | 52 ----------------------------------
1 file changed, 52 deletions(-)
diff --git a/payloads/libpayload/drivers/keyboard.c b/payloads/libpayload/drivers/keyboard.c
index cfb4d0b..e65f085 100644
--- a/payloads/libpayload/drivers/keyboard.c
+++ b/payloads/libpayload/drivers/keyboard.c
@@ -31,11 +31,6 @@
#include <libpayload-config.h>
#include <libpayload.h>
-#define I8042_CMD_READ_MODE 0x20
-#define I8042_CMD_WRITE_MODE 0x60
-
-#define I8042_MODE_XLATE 0x40
-
struct layout_maps {
const char *country;
const unsigned short map[4][0x57];
@@ -261,40 +256,6 @@ int keyboard_getchar(void)
return ret;
}
-static int keyboard_wait_read(void)
-{
- int retries = 10000;
-
- while(retries-- && !(inb(0x64) & 0x01))
- udelay(50);
-
- return (retries <= 0) ? -1 : 0;
-}
-
-static int keyboard_wait_write(void)
-{
- int retries = 10000;
-
- while(retries-- && (inb(0x64) & 0x02))
- udelay(50);
-
- return (retries <= 0) ? -1 : 0;
-}
-
-static unsigned char keyboard_get_mode(void)
-{
- outb(I8042_CMD_READ_MODE, 0x64);
- keyboard_wait_read();
- return inb(0x60);
-}
-
-static void keyboard_set_mode(unsigned char mode)
-{
- outb(I8042_CMD_WRITE_MODE, 0x64);
- keyboard_wait_write();
- outb(mode, 0x60);
-}
-
/**
* Set keyboard layout
* @param country string describing the keyboard layout language.
@@ -326,29 +287,16 @@ static struct console_input_driver cons = {
void keyboard_init(void)
{
- u8 mode;
map = &keyboard_layouts[0];
/* If 0x64 returns 0xff, then we have no keyboard
* controller */
-
if (inb(0x64) == 0xFF)
return;
/* Empty keyboard buffer */
while (keyboard_havechar()) keyboard_getchar();
- /* Read the current mode */
- mode = keyboard_get_mode();
-
- /* Turn on scancode translate mode so that we can
- use the scancode set 1 tables */
-
- mode |= I8042_MODE_XLATE;
-
- /* Write the new mode */
- keyboard_set_mode(mode);
-
console_add_input_driver(&cons);
}
Shawn Nematbakhsh (shawnn(a)chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3883
-gerrit
commit 11456c27af4f55c1f6fc3f6f5e495eab4d722766
Author: Shawn Nematbakhsh <shawnn(a)chromium.org>
Date: Fri Aug 23 14:12:24 2013 -0700
libpayload: Remove unnecessary keyboard mode setting code
keyboard_init attempts to read the existing mode register, set the
'XLATE' bit, and write it back. The implementation is buggy because the
keyboard may be active at the time we read the mode, and we can
misinterpret scancode data as the reply to our command. It leads to
problems where the KB gets disabled in firmware.
In fact, setting the 'XLATE' bit is completely unnecessary, even if we
desire QEMU keyboard support. We already set this bit when we initialize
the keyboard in pc_keyboard_init. Basically, this code does nothing
(or worse), so just remove it.
Change-Id: Iab23f03fa8bced74842c33a7d263de5f449bb983
Signed-off-by: Shawn Nematbakhsh <shawnn(a)chromium.org>
---
payloads/libpayload/drivers/keyboard.c | 55 ----------------------------------
1 file changed, 55 deletions(-)
diff --git a/payloads/libpayload/drivers/keyboard.c b/payloads/libpayload/drivers/keyboard.c
index cfb4d0b..3639507 100644
--- a/payloads/libpayload/drivers/keyboard.c
+++ b/payloads/libpayload/drivers/keyboard.c
@@ -31,11 +31,6 @@
#include <libpayload-config.h>
#include <libpayload.h>
-#define I8042_CMD_READ_MODE 0x20
-#define I8042_CMD_WRITE_MODE 0x60
-
-#define I8042_MODE_XLATE 0x40
-
struct layout_maps {
const char *country;
const unsigned short map[4][0x57];
@@ -261,40 +256,6 @@ int keyboard_getchar(void)
return ret;
}
-static int keyboard_wait_read(void)
-{
- int retries = 10000;
-
- while(retries-- && !(inb(0x64) & 0x01))
- udelay(50);
-
- return (retries <= 0) ? -1 : 0;
-}
-
-static int keyboard_wait_write(void)
-{
- int retries = 10000;
-
- while(retries-- && (inb(0x64) & 0x02))
- udelay(50);
-
- return (retries <= 0) ? -1 : 0;
-}
-
-static unsigned char keyboard_get_mode(void)
-{
- outb(I8042_CMD_READ_MODE, 0x64);
- keyboard_wait_read();
- return inb(0x60);
-}
-
-static void keyboard_set_mode(unsigned char mode)
-{
- outb(I8042_CMD_WRITE_MODE, 0x64);
- keyboard_wait_write();
- outb(mode, 0x60);
-}
-
/**
* Set keyboard layout
* @param country string describing the keyboard layout language.
@@ -326,29 +287,13 @@ static struct console_input_driver cons = {
void keyboard_init(void)
{
- u8 mode;
map = &keyboard_layouts[0];
/* If 0x64 returns 0xff, then we have no keyboard
* controller */
-
if (inb(0x64) == 0xFF)
return;
- /* Empty keyboard buffer */
- while (keyboard_havechar()) keyboard_getchar();
-
- /* Read the current mode */
- mode = keyboard_get_mode();
-
- /* Turn on scancode translate mode so that we can
- use the scancode set 1 tables */
-
- mode |= I8042_MODE_XLATE;
-
- /* Write the new mode */
- keyboard_set_mode(mode);
-
console_add_input_driver(&cons);
}
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3881
-gerrit
commit 69c95e23b3944f4921a58ffd12c491513d206e3f
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Mon Aug 19 12:45:16 2013 +0300
usbdebug: Adjust transaction retries
Transaction consistently completes with 80 to 150 status reads on my
setups. Hardware should always be able to complete this within 125us
as the debug port is serviced at the beginning of each microframe.
Timeout is set to DBGP_MICROFRAME_TIMEOUT_US=1000 status reads. Do not
retry transactions if this timeout is reached as the host controller
probably needs full re-initialisation to recover.
If this timeout is not reached, but a transaction is corrupted
on the wire, or it is otherwise not properly delivered to the USB device,
transaction is retried upto DBGP_MICROFRAME_RETRIES=10 times.
Change-Id: I44bc0a1bd194cdb5a2c13d5b81fc39bc568ae054
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
src/lib/usbdebug.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/src/lib/usbdebug.c b/src/lib/usbdebug.c
index 60a0aa6..4ff2deb 100644
--- a/src/lib/usbdebug.c
+++ b/src/lib/usbdebug.c
@@ -107,6 +107,8 @@ static int dbgp_enabled(void);
#define HUB_LONG_RESET_TIME 200
#define HUB_RESET_TIMEOUT 500
+#define DBGP_MICROFRAME_TIMEOUT_US 1000
+#define DBGP_MICROFRAME_RETRIES 10
#define DBGP_MAX_PACKET 8
#define DBGP_LOOPS 1000
@@ -124,17 +126,17 @@ static inline struct ehci_debug_info *dbgp_ehci_info(void)
static int dbgp_wait_until_complete(struct ehci_dbg_port *ehci_debug)
{
u32 ctrl;
- int loop = 0x100000;
+ int loop = 0;
do {
ctrl = read32((unsigned long)&ehci_debug->control);
/* Stop when the transaction is finished */
if (ctrl & DBGP_DONE)
break;
- } while (--loop > 0);
+ } while (++loop < DBGP_MICROFRAME_TIMEOUT_US);
- if (!loop)
- return -1;
+ if (! (ctrl & DBGP_DONE))
+ return -DBGP_ERR_SIGNAL;
/* Now that we have observed the completed transaction,
* clear the done bit.
@@ -153,18 +155,25 @@ static int dbgp_wait_until_done(struct ehci_dbg_port *ehci_debug, struct dbgp_pi
{
u32 rd_ctrl, rd_pids;
u8 lpid;
- int ret;
+ int ret, host_retries;
retry:
+ host_retries = 0;
+host_retry:
+ if (host_retries++ >= DBGP_MICROFRAME_RETRIES)
+ return -DBGP_ERR_BAD;
write32((unsigned long)&ehci_debug->control, ctrl | DBGP_GO);
ret = dbgp_wait_until_complete(ehci_debug);
rd_ctrl = read32((unsigned long)&ehci_debug->control);
rd_pids = read32((unsigned long)&ehci_debug->pids);
- if (ret < 0) {
- if (ret == -DBGP_ERR_BAD && --loop > 0)
- goto retry;
+ /* Controller hardware failure. */
+ if (ret == -DBGP_ERR_SIGNAL) {
return ret;
+
+ /* Bus failure (corrupted microframe). */
+ } else if (ret == -DBGP_ERR_BAD) {
+ goto host_retry;
}
lpid = DBGP_PID_GET(rd_pids);
Kyösti Mälkki (kyosti.malkki(a)gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3861
-gerrit
commit 482d31f295e74b75faa8f6cac65516217a650e34
Author: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Date: Mon Aug 12 00:09:21 2013 +0300
usbdebug: Only test two possible USB device numbers
After an USB device sees USB bus reset on the bus, it will reset to
device number 0. Per the EHCI debug port specification, a debug
dongle device may reset to the fixed debug device number of 127 instead.
Thus there is no need to try device numbers from 1 to 126.
Do a sanity-check on a returned debug descriptor as I experienced
some USB flash memory to respond on this request with zero-fill data.
Change-Id: I78d58f3dc049cd8c20c6e2aa3a4207ad7e6a6d33
Signed-off-by: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
---
src/lib/usbdebug.c | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/src/lib/usbdebug.c b/src/lib/usbdebug.c
index a9a7e17..4a1228f 100644
--- a/src/lib/usbdebug.c
+++ b/src/lib/usbdebug.c
@@ -540,24 +540,28 @@ try_next_port:
dbgp_mdelay(100);
/* Find the debug device and make it device number 127 */
- for (devnum = 0; devnum <= 127; devnum++) {
- ret = dbgp_control_msg(ehci_debug, devnum,
- USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
- USB_REQ_GET_DESCRIPTOR, (USB_DT_DEBUG << 8), 0,
- &dbgp_desc, sizeof(dbgp_desc));
- if (ret > 0)
- break;
+ devnum = 0;
+debug_dev_retry:
+ memset(&dbgp_desc, 0, sizeof(dbgp_desc));
+ ret = dbgp_control_msg(ehci_debug, devnum,
+ USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
+ USB_REQ_GET_DESCRIPTOR, (USB_DT_DEBUG << 8), 0,
+ &dbgp_desc, sizeof(dbgp_desc));
+ if (ret == sizeof(dbgp_desc)) {
+ if (dbgp_desc.bLength == sizeof(dbgp_desc) && dbgp_desc.bDescriptorType==USB_DT_DEBUG)
+ goto debug_dev_found;
+ else
+ dprintk(BIOS_INFO, "Invalid debug device descriptor.\n");
}
- if (devnum > 127) {
+ if (devnum == 0) {
+ devnum = USB_DEBUG_DEVNUM;
+ goto debug_dev_retry;
+ } else {
dprintk(BIOS_INFO, "Could not find attached debug device.\n");
ret = -5;
goto err;
}
- if (ret < 0) {
- dprintk(BIOS_INFO, "Attached device is not a debug device.\n");
- ret = -6;
- goto err;
- }
+debug_dev_found:
/* Move the device to 127 if it isn't already there */
if (devnum != USB_DEBUG_DEVNUM) {