From patchwork Sun Sep 25 18:05:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Schwierzeck X-Patchwork-Id: 674644 X-Patchwork-Delegate: daniel.schwierzeck@googlemail.com 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 3shw5y3CZrz9s65 for ; Mon, 26 Sep 2016 04:06:46 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=yQWwo7+n; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CC8BDA7696; Sun, 25 Sep 2016 20:06:26 +0200 (CEST) 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 WgRwkzKvyvQW; Sun, 25 Sep 2016 20:06:26 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1F9F6A76A6; Sun, 25 Sep 2016 20:06:08 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7DEFBA75F3 for ; Sun, 25 Sep 2016 20:05:58 +0200 (CEST) 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 fhuPymQx806w for ; Sun, 25 Sep 2016 20:05:58 +0200 (CEST) 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-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by theia.denx.de (Postfix) with ESMTPS id 45112A7550 for ; Sun, 25 Sep 2016 20:05:56 +0200 (CEST) Received: by mail-wm0-f67.google.com with SMTP id 133so10789566wmq.2 for ; Sun, 25 Sep 2016 11:05:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0am+DjvDYYciyPoJ7HktMn3fu8Qaz5Xp9RQNaf9agb4=; b=yQWwo7+nqaZls2vS/fGFw+I75UzYvtUUi64CpIJy7t+xKtdYGP6tDLFZ9HKBUbaCUK PVtBu54FwzeedL4scVyS/DyI0NMbxCIhPdJP9GMjjqfPQ5fTJp2BX0nucwwxiE7PAN4E uPQ7qwZJ0CcN79M61gAWuPraEz0fBdmhU+NkTk1RNsWW+gzeKDTFeKJgWv5cTB7J/0ES UTeiPjo8VuZSGqS7C7Q9E5FkMwPgNro6lCW1umLbxbzbk/Bij7xaiVYJ90WDXQC85pr8 FZ+4h2TqgNoLCLYT4ihurAfF95mufmpo5YTFIM306bXtiAf+CgA4ys61zPeSkrz5KmbT Wiow== 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=0am+DjvDYYciyPoJ7HktMn3fu8Qaz5Xp9RQNaf9agb4=; b=V0aIPeWMQszcpQ3q1H6PI5DRcN7dI5gs2dxstAsqdmxHvVev0tsVagVNW1RC8l6Se2 Q8v4U29+IMJnI8BdNzz8OqaEXlFnPCKJC6MWSaX/Vxl6mesL8PSir8GgjRhxI16MeOLF lAnFoeh/Pi2vPuzuBt/e7rNFxnj+ICWqtMtTsdM5lo6J5KNT5VrkCzJzC+hJAHqTGDhJ uBG/g5T/3Zv0xdq5IairYyjcTOVNiAlHe01N+fl0PrBa4RFbptkpl7ho4uv6sj86o94T ycHTEMQ0q3hKQ2/NCx6XOGEjTPcUf7nQxz5Bt21sdiW3Sd/RW2ZqEn3PYrOBWMK9NcMm X5pg== X-Gm-Message-State: AA6/9RkU3KVEDXz5KVlz7Ptw372b+Jj6cKjb2mmtidLbTJkJOwzai2YzmFLbN4mN6mjPzA== X-Received: by 10.28.48.19 with SMTP id w19mr11743093wmw.54.1474826755837; Sun, 25 Sep 2016 11:05:55 -0700 (PDT) Received: from workstation.zombienet.local (p2003005F2C23240162A44CFFFE5E9229.dip0.t-ipconnect.de. [2003:5f:2c23:2401:62a4:4cff:fe5e:9229]) by smtp.gmail.com with ESMTPSA id p13sm7042758wmd.1.2016.09.25.11.05.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 25 Sep 2016 11:05:54 -0700 (PDT) From: Daniel Schwierzeck To: u-boot@lists.denx.de Date: Sun, 25 Sep 2016 20:05:26 +0200 Message-Id: <20160925180532.19800-4-daniel.schwierzeck@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160925180532.19800-1-daniel.schwierzeck@gmail.com> References: <20160925180532.19800-1-daniel.schwierzeck@gmail.com> Cc: Marek Vasut , Purna Chandra Mandal , Wills Wang Subject: [U-Boot] [PATCH 3/9] MIPS: fix iand optimize setup of CP0 registers X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Clear cp0 status while preserving implementation specific bits. Set bits BEV and ERL as the arch specification requires after a reset or soft-reset exception. Extend and fix initialization of watch registers. Check if additional watch register sets are implemented and initialize them too. Initialize cp0 count as early as possible to get the most accurate boot timing. Signed-off-by: Daniel Schwierzeck --- arch/mips/cpu/start.S | 74 +++++++++++++++++++++++++++------------- arch/mips/include/asm/mipsregs.h | 1 + 2 files changed, 51 insertions(+), 24 deletions(-) diff --git a/arch/mips/cpu/start.S b/arch/mips/cpu/start.S index 6886036..c909ffa 100644 --- a/arch/mips/cpu/start.S +++ b/arch/mips/cpu/start.S @@ -34,28 +34,20 @@ # define STATUS_SET ST0_KX #endif - /* - * For the moment disable interrupts, mark the kernel mode and - * set ST0_KX so that the CPU does not spit fire when using - * 64-bit addresses. - */ - .macro setup_c0_status set clr - .set push - mfc0 t0, CP0_STATUS - or t0, ST0_CU0 | \set | 0x1f | \clr - xor t0, 0x1f | \clr - mtc0 t0, CP0_STATUS - .set noreorder - sll zero, 3 # ehb - .set pop - .endm - .set noreorder + .macro init_wr sel + MTC0 zero, CP0_WATCHLO,\sel + mtc0 t1, CP0_WATCHHI,\sel + mfc0 t0, CP0_WATCHHI,\sel + bgez t0, wr_done + nop + .endm + ENTRY(_start) /* U-Boot entry point */ b reset - nop + mtc0 zero, CP0_COUNT # clear cp0 count for most accurate boot timing #if defined(CONFIG_SYS_XWAY_EBU_BOOTCFG) /* @@ -133,17 +125,51 @@ reset: b 3b nop - /* Clear watch registers */ -4: MTC0 zero, CP0_WATCHLO + /* Init CP0 Status */ +4: mfc0 t0, CP0_STATUS + and t0, ST0_IMPL + or t0, ST0_BEV | ST0_ERL | STATUS_SET + mtc0 t0, CP0_STATUS + + /* + * Check whether CP0 Config1 is implemented. If not continue + * with legacy Watch register initialization. + */ + mfc0 t0, CP0_CONFIG + bgez t0, wr_legacy + nop + + /* + * Check WR bit in CP0 Config1 to determine if Watch registers + * are implemented. + */ + mfc0 t0, CP0_CONFIG, 1 + andi t0, (1 << 3) + beqz t0, wr_done + nop + + /* Clear Watch Status bits and disable watch exceptions */ + li t1, 0x7 # Clear I, R and W conditions + init_wr 0 + init_wr 1 + init_wr 2 + init_wr 3 + init_wr 4 + init_wr 5 + init_wr 6 + init_wr 7 + b wr_done + nop + +wr_legacy: + MTC0 zero, CP0_WATCHLO mtc0 zero, CP0_WATCHHI - /* WP(Watch Pending), SW0/1 should be cleared */ +wr_done: + /* Clear WP, IV and SW interrupts */ mtc0 zero, CP0_CAUSE - setup_c0_status STATUS_SET 0 - - /* Init Timer */ - mtc0 zero, CP0_COUNT + /* Clear timer interrupt (CP0_COUNT cleared on branch to 'reset') */ mtc0 zero, CP0_COMPARE #ifndef CONFIG_SKIP_LOWLEVEL_INIT diff --git a/arch/mips/include/asm/mipsregs.h b/arch/mips/include/asm/mipsregs.h index 9ab5063..7a9d222 100644 --- a/arch/mips/include/asm/mipsregs.h +++ b/arch/mips/include/asm/mipsregs.h @@ -299,6 +299,7 @@ #define STATUSF_IP14 (_ULCAST_(1) << 6) #define STATUSB_IP15 7 #define STATUSF_IP15 (_ULCAST_(1) << 7) +#define ST0_IMPL (_ULCAST_(3) << 16) #define ST0_CH 0x00040000 #define ST0_NMI 0x00080000 #define ST0_SR 0x00100000