From patchwork Mon Jul 9 09:20:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 169726 X-Patchwork-Delegate: monstr@monstr.eu 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 A83642C0210 for ; Mon, 9 Jul 2012 19:22:05 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C23C32816A; Mon, 9 Jul 2012 11:21:43 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 GeqZ7NAolzCN; Mon, 9 Jul 2012 11:21:43 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6C46328163; Mon, 9 Jul 2012 11:21:24 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0CE0D28130 for ; Mon, 9 Jul 2012 11:21:20 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 zdczUnPcu-ps for ; Mon, 9 Jul 2012 11:21:19 +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-wg0-f52.google.com (mail-wg0-f52.google.com [74.125.82.52]) by theia.denx.de (Postfix) with ESMTPS id 12F3D2814A for ; Mon, 9 Jul 2012 11:21:11 +0200 (CEST) Received: by wgbgn7 with SMTP id gn7so11442565wgb.9 for ; Mon, 09 Jul 2012 02:21:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=8JoGjz3Dv9ySGgrEvZZlWT5ajDXQIrkJPdORUfmjnkI=; b=eZ0Gf/MXd0JyiLr0UsyoKjnbyiLFF9K3nZgx9u5wZtj7ox3ss4ZsVokgOCve1ZrBtb oIZfNrjXBtP5AA9Eh6e+KYGHGxP/yBIHLxsqGZ1HLj03W79o8TGDpg2PkF3QeV0n7e5V tTJIZK4uYAgb77B1UCHGCtPka0SnaaoGHkyOVgNUlejDL+AYp86PTlf+OzVD07Y/WSW0 fGf8gBKnTwvmoSSoF5wtT/9EspAIQHLg6LJX8YN34fMRdfp388VmDYf6hllklktSFojb Z9+mVxsugCptXp2t/pF3eu//fcoTp4JWaToHAiTGP9YH+YKXTCV9zUVuvpjZ8dJruVD/ VOrA== Received: by 10.216.136.203 with SMTP id w53mr15936251wei.63.1341825668957; Mon, 09 Jul 2012 02:21:08 -0700 (PDT) Received: from localhost (11.161.broadband5.iol.cz. [88.100.161.11]) by mx.google.com with ESMTPS id q6sm23151271wiy.0.2012.07.09.02.21.07 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 09 Jul 2012 02:21:08 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de Date: Mon, 9 Jul 2012 11:20:36 +0200 Message-Id: <1341825639-23475-9-git-send-email-monstr@monstr.eu> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1341825639-23475-1-git-send-email-monstr@monstr.eu> References: <1341825639-23475-1-git-send-email-monstr@monstr.eu> X-Gm-Message-State: ALoCoQlenoaNxF4sdkpau+T0q5zIp0A+oZF8h7hIIZRtrsUfu2Cyz0XXLrU9q/Sh5dFtQj9fqJpI Cc: linz@li-pro.net Subject: [U-Boot] [PATCH 09/12] microblaze: timer: Add device-tree driver configuration X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 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 Read configuration from DTB. Signed-off-by: Michal Simek --- arch/microblaze/cpu/timer.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/arch/microblaze/cpu/timer.c b/arch/microblaze/cpu/timer.c index dfaaaf5..91ca42b 100644 --- a/arch/microblaze/cpu/timer.c +++ b/arch/microblaze/cpu/timer.c @@ -25,6 +25,9 @@ #include #include #include +#include + +DECLARE_GLOBAL_DATA_PTR; volatile int timestamp = 0; microblaze_timer_t *tmr; @@ -62,11 +65,33 @@ int timer_init (void) u32 preload = 0; u32 ret = 0; +#ifndef CONFIG_OF_CONTROL #if defined(CONFIG_SYS_TIMER_0_ADDR) && defined(CONFIG_SYS_INTC_0_NUM) preload = XILINX_CLOCK_FREQ / CONFIG_SYS_HZ; irq = CONFIG_SYS_TIMER_0_IRQ; tmr = (microblaze_timer_t *) (CONFIG_SYS_TIMER_0_ADDR); #endif +#else + int temp; + int offset = 0; + + offset = fdt_node_offset_by_compatible(gd->fdt_blob, offset, + "xlnx,xps-timer-1.00.a"); + if (offset > 0) { + temp = fdtdec_get_addr(gd->fdt_blob, offset, "reg"); + if (temp != FDT_ADDR_T_NONE) { + tmr = (microblaze_timer_t *)temp; + irq = fdtdec_get_int(gd->fdt_blob, offset, + "interrupts", -1); + if (irq == -1) + panic("Connect IRQ to system timer\n"); + /* Set default clock frequency */ + temp = fdtdec_get_int(gd->fdt_blob, offset, + "clock-frequency", 0); + preload = temp / CONFIG_SYS_HZ; + } + } +#endif if (tmr && irq && preload) { tmr->loadreg = preload;