From patchwork Wed Oct 21 02:37:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lin Huang X-Patchwork-Id: 533628 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 14F28140787 for ; Wed, 21 Oct 2015 18:40:22 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 556EB4B681; Wed, 21 Oct 2015 09:40:10 +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 N0JvkXsUhOm7; Wed, 21 Oct 2015 09:40:10 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 538424B688; Wed, 21 Oct 2015 09:39:55 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D6D874B62A for ; Wed, 21 Oct 2015 04:37:46 +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 fin2zdssPgYs for ; Wed, 21 Oct 2015 04:37:46 +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-pa0-f66.google.com (mail-pa0-f66.google.com [209.85.220.66]) by theia.denx.de (Postfix) with ESMTPS id 6FAAE4B624 for ; Wed, 21 Oct 2015 04:37:42 +0200 (CEST) Received: by pagq8 with SMTP id q8so2867096pag.2 for ; Tue, 20 Oct 2015 19:37:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9MMr7Pmqk6kjudEwNDUMWOV3J19a+pOlajK/2yDZ2W8=; b=KBrcTL7C1t+ogKH2n6Pk4dqlNAau619vsZ9lRYT/vLTSmQsxMbSJWRJOyE7wOPsNC/ V5UWCkX3jxm73XPP0BYLTWDrU4D3I++UyR52D8E/gYI6d/goddoifUie6x50ykk2pFlE irCXcr8fGo/GPWJ24v3SjhGOvNuTi2CI1/aQmkyP7CWoQKxbdCb6cbk1bC6p2LLNBgtK TAypiFyNKxB99vl0ROkhoA7SUpXTcfgfeSOe0AZA4vgd2IExSjbdBqDqoBHEuxr8fjZH FRRdkb/fhUQeZjXMk/zFGfYfeeID3Wy8sfy6YXHAmdFvcpILfrYioVnqaWTQzqBe2mNW Hyeg== X-Received: by 10.66.216.101 with SMTP id op5mr7703392pac.51.1445395061627; Tue, 20 Oct 2015 19:37:41 -0700 (PDT) Received: from hl-HP-Compaq-dx7518-MT.example.org ([43.226.228.195]) by smtp.gmail.com with ESMTPSA id zi1sm6173586pbc.10.2015.10.20.19.37.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Oct 2015 19:37:41 -0700 (PDT) From: Lin Huang To: sjg@chromium.org Date: Wed, 21 Oct 2015 10:37:18 +0800 Message-Id: <1445395048-3703-3-git-send-email-hl@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1445395048-3703-1-git-send-email-hl@rock-chips.com> References: <1445395048-3703-1-git-send-email-hl@rock-chips.com> X-Mailman-Approved-At: Wed, 21 Oct 2015 09:39:46 +0200 Cc: cf@rock-chips.com, u-boot@lists.denx.de, zhengsq@rock-chips.com, trini@konsulko.com Subject: [U-Boot] [PATCH v1 02/12] rockchip: implement rockchip timer init function 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" now the timer init function implement in board-spl.c, but it may not use SPL in other board or other rockchip SOC, so implement timer init in common.c, we can call it if we need. Signed-off-by: Lin Huang Acked-by: Simon Glass --- Changes in v1: None arch/arm/include/asm/arch-rockchip/hardware.h | 2 +- arch/arm/include/asm/arch-rockchip/timer.h | 18 ++++++++++++++++++ arch/arm/mach-rockchip/board.c | 8 +++++++- arch/arm/mach-rockchip/common.c | 11 +++++++++++ include/configs/rk3288_common.h | 3 ++- 5 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 arch/arm/include/asm/arch-rockchip/timer.h diff --git a/arch/arm/include/asm/arch-rockchip/hardware.h b/arch/arm/include/asm/arch-rockchip/hardware.h index d5af5b8..44bd67a 100644 --- a/arch/arm/include/asm/arch-rockchip/hardware.h +++ b/arch/arm/include/asm/arch-rockchip/hardware.h @@ -11,7 +11,7 @@ #define RK_SETBITS(set) RK_CLRSETBITS(0, set) #define RK_CLRBITS(clr) RK_CLRSETBITS(clr, 0) -#define TIMER7_BASE 0xff810020 +#define TIMER_BASE CONFIG_SYS_TIMER_BASE #define rk_clrsetreg(addr, clr, set) writel((clr) << 16 | (set), addr) #define rk_clrreg(addr, clr) writel((clr) << 16, addr) diff --git a/arch/arm/include/asm/arch-rockchip/timer.h b/arch/arm/include/asm/arch-rockchip/timer.h new file mode 100644 index 0000000..57269e9 --- /dev/null +++ b/arch/arm/include/asm/arch-rockchip/timer.h @@ -0,0 +1,18 @@ +#ifndef __ASM_ARCH_TIMER_H +#define __ASM_ARCH_TIMER_H + +struct rk_timer { + unsigned int timer_load_count0; + unsigned int timer_load_count1; + unsigned int timer_curr_value0; + unsigned int timer_curr_value1; + unsigned int timer_ctrl_reg; + unsigned int timer_int_status; +}; + +/** + * timer_init() - rockchip timer init + */ +void rockchip_timer_init(void); + +#endif diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c index 688bc0f..789a801 100644 --- a/arch/arm/mach-rockchip/board.c +++ b/arch/arm/mach-rockchip/board.c @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: GPL-2.0+ */ - +#include #include #include #include @@ -12,6 +12,12 @@ DECLARE_GLOBAL_DATA_PTR; int board_init(void) { +#ifdef CONFIG_SPL_BUILD + + /* have been init in spl board */ +#else + rockchip_timer_init(); +#endif return 0; } diff --git a/arch/arm/mach-rockchip/common.c b/arch/arm/mach-rockchip/common.c index fc7ac72..eaf8bc1 100644 --- a/arch/arm/mach-rockchip/common.c +++ b/arch/arm/mach-rockchip/common.c @@ -4,6 +4,8 @@ * SPDX-License-Identifier: GPL-2.0+ */ +#include +#include #include #include #include @@ -26,3 +28,12 @@ void *rockchip_get_cru(void) return (void *)addr; } + +void rockchip_timer_init(void) +{ + struct rk_timer * const timer_ptr = (void *)TIMER_BASE; + + writel(0xffffffff, &timer_ptr->timer_load_count0); + writel(0xffffffff, &timer_ptr->timer_load_count1); + writel(1, &timer_ptr->timer_ctrl_reg); +} diff --git a/include/configs/rk3288_common.h b/include/configs/rk3288_common.h index e8aec28..b4d040e 100644 --- a/include/configs/rk3288_common.h +++ b/include/configs/rk3288_common.h @@ -24,7 +24,8 @@ #define CONFIG_DISPLAY_BOARDINFO #define CONFIG_SYS_TIMER_RATE (24 * 1000 * 1000) -#define CONFIG_SYS_TIMER_COUNTER (TIMER7_BASE + 8) +#define CONFIG_SYS_TIMER_BASE 0xff810020 /* TIMER7 */ +#define CONFIG_SYS_TIMER_COUNTER (CONFIG_SYS_TIMER_BASE + 8) #define CONFIG_SPL_FRAMEWORK #define CONFIG_SPL_LIBCOMMON_SUPPORT