From patchwork Fri Nov 13 08:11:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 544105 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 304D21409A0 for ; Fri, 13 Nov 2015 19:08:52 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=TKuvDOfp; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BFF494BAB2; Fri, 13 Nov 2015 09:08:50 +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 egE5p56d3VSD; Fri, 13 Nov 2015 09:08:50 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0AAE24BAB8; Fri, 13 Nov 2015 09:08:50 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9BA1B4BAB2 for ; Fri, 13 Nov 2015 09:08:45 +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 DYWwOw3R2Nu0 for ; Fri, 13 Nov 2015 09:08:45 +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-pa0-f42.google.com (mail-pa0-f42.google.com [209.85.220.42]) by theia.denx.de (Postfix) with ESMTPS id 10A3B4BAC2 for ; Fri, 13 Nov 2015 09:08:41 +0100 (CET) Received: by padhx2 with SMTP id hx2so93125659pad.1 for ; Fri, 13 Nov 2015 00:08:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=E6USOeuI74e8RGP12d0d43I+wghO3f2YIFtm18a0RQk=; b=TKuvDOfph5yrYb5KxWCh/ngrQy1NzTudrFTg1M9idHgNZxxZ+ClcmONnFl+TSCNC9N EROb0jWtkGzz2OtQnma8m6pFLkhLvbZK01XbI9xomHpSh26pbhPKdeNK0q2yKZOPKVg+ dwRHe3U5G20bn5akd/+ypDjansLeaiwZ6UOk0VBX7I7kNH/53LsY/CPzpHQ798UIT6wG PxobBA28McwVRuOwLX2GinAzUNiAq9sKRxCcfE+yO8ddjKxUhSCTrT8NoBlZKRdyNqc9 XPN8DwYSlSMct5MmL0tBfUt5NLcDYmdTbSlWQDp9LXMHZDedUTpFP1kdvd9wiBqCKHOZ KiFA== X-Received: by 10.66.136.40 with SMTP id px8mr6555824pab.75.1447402120529; Fri, 13 Nov 2015 00:08:40 -0800 (PST) Received: from ala-d2121-lx1.wrs.com (unknown-157-139.windriver.com. [147.11.157.139]) by smtp.gmail.com with ESMTPSA id h10sm18857209pat.7.2015.11.13.00.08.39 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Nov 2015 00:08:40 -0800 (PST) From: Bin Meng To: Simon Glass , Thomas Chou , U-Boot Mailing List Date: Fri, 13 Nov 2015 00:11:15 -0800 Message-Id: <1447402284-26598-3-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1447402284-26598-1-git-send-email-bmeng.cn@gmail.com> References: <1447402284-26598-1-git-send-email-bmeng.cn@gmail.com> Subject: [U-Boot] [PATCH v3 02/11] dm: timer: Implement pre_probe() 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" Every timer device needs to have a valid clock frequency and it can be specified in the device tree. Use pre_probe() to get this in the timer uclass driver. Signed-off-by: Bin Meng Acked-by: Thomas Chou Acked-by: Simon Glass --- Changes in v3: None Changes in v2: None drivers/timer/timer-uclass.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c index 82c6897..0218591 100644 --- a/drivers/timer/timer-uclass.c +++ b/drivers/timer/timer-uclass.c @@ -9,6 +9,8 @@ #include #include +DECLARE_GLOBAL_DATA_PTR; + /* * Implement a timer uclass to work with lib/time.c. The timer is usually * a 32 bits free-running up counter. The get_rate() method is used to get @@ -35,8 +37,19 @@ unsigned long timer_get_rate(struct udevice *dev) return uc_priv->clock_rate; } +static int timer_pre_probe(struct udevice *dev) +{ + struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev); + + uc_priv->clock_rate = fdtdec_get_int(gd->fdt_blob, dev->of_offset, + "clock-frequency", 0); + + return 0; +} + UCLASS_DRIVER(timer) = { .id = UCLASS_TIMER, .name = "timer", + .pre_probe = timer_pre_probe, .per_device_auto_alloc_size = sizeof(struct timer_dev_priv), };