From patchwork Tue Nov 11 01:00:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 409156 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 47D1D14011B for ; Tue, 11 Nov 2014 12:10:20 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 49C524B653; Tue, 11 Nov 2014 02:10:18 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1pg3o4Zj85gR; Tue, 11 Nov 2014 02:10:18 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CA8C94B60F; Tue, 11 Nov 2014 02:10:17 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E3A744B617 for ; Tue, 11 Nov 2014 02:10:14 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9+9ADD3Qn4Ot for ; Tue, 11 Nov 2014 02:10:14 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pd0-f201.google.com (mail-pd0-f201.google.com [209.85.192.201]) by theia.denx.de (Postfix) with ESMTPS id 7CA284B60C for ; Tue, 11 Nov 2014 02:10:10 +0100 (CET) Received: by mail-pd0-f201.google.com with SMTP id r10so1431993pdi.4 for ; Mon, 10 Nov 2014 17:10:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uDk6FWYsUlHwaVhFrDxUMuBMXCngE82aVXvKLkxmdUU=; b=XyTq52q9EcUANLCCRtK9f8RqlzY7QMawhAWU+j7d2YFZIU2MeGd1P2j3moi455wlw3 Nqx240NvKpOzvtnq5Z8r7bhCNCOlHWO5sXMmpw7bg6F1T8OQCpHTmdHALPiwBN2Azrmn /HEgNS/7X/vBOlJcIPZO3vWg/e9DZeNe3BVghdLvklIqEmgnk+qWPpZ54jgoAZCm6cK+ obK0L3NNV8USXBNZzKLmqn1XMQGYIlh6yQ/KK/i4zcUnLozZR9tgjqvlRHNqve7lw/49 tAYNQphWRdNhUeHx/kHy9YiVjO9HJ7cCdZb4j7r4Zw76NO4+B5kMzi7Yyhqn7Y98eyQ/ LFtg== X-Gm-Message-State: ALoCoQnSLZH0CwyaBOJ6NehpK4KlgflL62GIwcSYtO+elj4umu9DTIaRU5iffrWce5q70J4EbDXO X-Received: by 10.66.144.198 with SMTP id so6mr26520584pab.25.1415668209349; Mon, 10 Nov 2014 17:10:09 -0800 (PST) Received: from corpmail-nozzle1-2.hot.corp.google.com ([100.108.1.103]) by gmr-mx.google.com with ESMTPS id t28si749218yhb.4.2014.11.10.17.10.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Nov 2014 17:10:09 -0800 (PST) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by corpmail-nozzle1-2.hot.corp.google.com with ESMTP id 2v19whex.1; Mon, 10 Nov 2014 17:10:09 -0800 Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 868652211EA; Mon, 10 Nov 2014 18:01:14 -0700 (MST) From: Simon Glass To: U-Boot Mailing List Date: Mon, 10 Nov 2014 18:00:30 -0700 Message-Id: <1415667650-14899-14-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 In-Reply-To: <1415667650-14899-1-git-send-email-sjg@chromium.org> References: <1415667650-14899-1-git-send-email-sjg@chromium.org> Cc: Graeme Russ Subject: [U-Boot] [PATCH v2 13/33] x86: Emit post codes in startup code for Chromebooks X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de On x86 it is common to use 'post codes' which are 8-bit hex values emitted from the code and visible to the user. Traditionally two 7-segment displays were made available on the motherboard to show the last post code that was emitted. This allows diagnosis of a boot problem since it is possible to see where the code got to before it died. On modern hardware these codes are not normally visible. On Chromebooks they are displayed by the Embedded Controller (EC), so it is useful to emit them. We must enable this feature for the EC to see the codes, so add an option for this. Signed-off-by: Simon Glass --- Changes in v2: - Move early init code into early_board_init arch/x86/cpu/coreboot/coreboot.c | 3 ++- arch/x86/cpu/start.S | 4 ++++ arch/x86/include/asm/post.h | 32 ++++++++++++++++++++++++++++++++ board/google/chromebook_link/Kconfig | 4 ++++ board/google/common/early_init.S | 21 ++++++++++++++++++++- 5 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 arch/x86/include/asm/post.h diff --git a/arch/x86/cpu/coreboot/coreboot.c b/arch/x86/cpu/coreboot/coreboot.c index 874b59d..d9662d9 100644 --- a/arch/x86/cpu/coreboot/coreboot.c +++ b/arch/x86/cpu/coreboot/coreboot.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -70,7 +71,7 @@ void show_boot_progress(int val) gd->arch.tsc_prev = now; } #endif - outb(val, 0x80); + outb(val, POST_PORT); } int last_stage_init(void) diff --git a/arch/x86/cpu/start.S b/arch/x86/cpu/start.S index b18f320..1b738f9 100644 --- a/arch/x86/cpu/start.S +++ b/arch/x86/cpu/start.S @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -67,6 +68,7 @@ _start: jmp early_board_init .globl early_board_init_ret early_board_init_ret: + post_code(POST_START) /* Initialise Cache-As-RAM */ jmp car_init @@ -96,6 +98,7 @@ car_init_ret: /* Align global data to 16-byte boundary */ andl $0xfffffff0, %esp + post_code(POST_START_STACK) /* Zero the global data since it won't happen later */ xorl %eax, %eax @@ -131,6 +134,7 @@ car_init_ret: call setup_gdt /* Set parameter to board_init_f() to boot flags */ + post_code(POST_START_DONE) xorl %eax, %eax /* Enter, U-boot! */ diff --git a/arch/x86/include/asm/post.h b/arch/x86/include/asm/post.h new file mode 100644 index 0000000..3371185 --- /dev/null +++ b/arch/x86/include/asm/post.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2014 Google, Inc + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef _post_h +#define _post_h + +/* port to use for post codes */ +#define POST_PORT 0x80 + +/* post codes which represent various stages of init */ +#define POST_START 0x1e +#define POST_CAR_START 0x1f + +#define POST_START_STACK 0x29 +#define POST_START_DONE 0x2a + +/* Output a post code using al - value must be 0 to 0xff */ +#ifdef __ASSEMBLY__ +#define post_code(value) \ + movb $value, %al; \ + outb %al, $POST_PORT +#else +static inline void post_code(int code) +{ + outb(code, POST_PORT); +} +#endif + +#endif diff --git a/board/google/chromebook_link/Kconfig b/board/google/chromebook_link/Kconfig index 975d557..9c715ba 100644 --- a/board/google/chromebook_link/Kconfig +++ b/board/google/chromebook_link/Kconfig @@ -12,4 +12,8 @@ config SYS_SOC config SYS_CONFIG_NAME default "chromebook_link" +config EARLY_POST_CROS_EC + bool "Enable early post to Chrome OS EC" + default y + endif diff --git a/board/google/common/early_init.S b/board/google/common/early_init.S index cf70ae4..15f2ff2 100644 --- a/board/google/common/early_init.S +++ b/board/google/common/early_init.S @@ -6,5 +6,24 @@ .globl early_board_init early_board_init: - /* No 32-bit board specific initialisation */ + /* Enable post codes to EC */ +#ifdef CONFIG_EARLY_POST_CROS_EC + mov $0x1b, %ecx + rdmsr + and $0x100, %eax + test %eax, %eax + je 2f + + mov $0x8000f8f0, %eax + mov $0xcf8, %dx + out %eax, (%dx) + mov $0xfed1c001, %eax + mov $0xcfc, %dx + out %eax, (%dx) + mov $0xfed1f410, %esp + mov (%esp), %eax + and $0xfffffffb, %eax + mov %eax, (%esp) +2: +#endif jmp early_board_init_ret