From patchwork Wed Aug 21 09:49:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sunshaojie X-Patchwork-Id: 19365 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gh0-f199.google.com (mail-gh0-f199.google.com [209.85.160.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DAA6C248E6 for ; Wed, 21 Aug 2013 09:49:45 +0000 (UTC) Received: by mail-gh0-f199.google.com with SMTP id g14sf157411ghb.10 for ; Wed, 21 Aug 2013 02:49:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=ADS95Tsp2Ze8AhopVk7OZc8+o8Z+iaipUtjkRXoNkjk=; b=CGXELPPUsMCoKqhLLEyRkRWuIvbQ7VSPZTcyuBCSnef1C1jKtKy0DxsS876qpbTBe/ AlzJRUWf8v4mZhoHDln2/6oc57aVbTp4WVXCKhWgP8Ogd/Fm7qjPLJOEPZmTVEOWsN7W LzXAXaDhCzuviZIx0sca28woiV7NloLdc3wEVCfNZijwHEhZpJkBjdJZXgNan4N4D6i/ UUHsRQrFPtWtaqgdqvODs2rissyJOFBO/KHvkljSnFgCGx5OPNlBs+00NIA0yotZTDVA guuJ3u1aaCjSEygN++B5i/XCjKk/HUyBT/8PIFA45i/hy6vECJeZXiTbugkd93A4X5BM O7UA== X-Received: by 10.224.137.68 with SMTP id v4mr8614491qat.1.1377078585649; Wed, 21 Aug 2013 02:49:45 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.4.8 with SMTP id g8ls546128qeg.67.gmail; Wed, 21 Aug 2013 02:49:45 -0700 (PDT) X-Received: by 10.52.165.45 with SMTP id yv13mr4810208vdb.1.1377078585550; Wed, 21 Aug 2013 02:49:45 -0700 (PDT) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id wk9si1868765vdb.29.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 Aug 2013 02:49:45 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id m1so142687ves.27 for ; Wed, 21 Aug 2013 02:49:45 -0700 (PDT) X-Gm-Message-State: ALoCoQkQ0/MVLCuF9wQVLPxl/JPRODvK/1KR6Hu7Z+Yapy9GgyDVXPDVTtUE3JJ6Wk2IggO9cagD X-Received: by 10.58.100.234 with SMTP id fb10mr5755875veb.5.1377078585441; Wed, 21 Aug 2013 02:49:45 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp209543vcz; Wed, 21 Aug 2013 02:49:44 -0700 (PDT) X-Received: by 10.68.191.231 with SMTP id hb7mr6740830pbc.82.1377078584510; Wed, 21 Aug 2013 02:49:44 -0700 (PDT) Received: from mail-pa0-f54.google.com (mail-pa0-f54.google.com [209.85.220.54]) by mx.google.com with ESMTPS id co1si4609761pbc.138.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 Aug 2013 02:49:44 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.54 is neither permitted nor denied by best guess record for domain of shaojie.sun@linaro.org) client-ip=209.85.220.54; Received: by mail-pa0-f54.google.com with SMTP id kx10so643424pab.27 for ; Wed, 21 Aug 2013 02:49:44 -0700 (PDT) X-Received: by 10.68.130.71 with SMTP id oc7mr6938733pbb.10.1377078584038; Wed, 21 Aug 2013 02:49:44 -0700 (PDT) Received: from localhost.localdomain ([58.251.159.202]) by mx.google.com with ESMTPSA id zq10sm9115696pab.6.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 Aug 2013 02:49:43 -0700 (PDT) From: Shaojie Sun To: sanjay.rawat@linaro.org Cc: patches@linaro.org, private-pmwg@linaro.org, sunshaojie@huawei.com, Shaojie Sun Subject: [PATCH POWERDEBUG 2/2] The clock rates that are reported are incorrect Date: Wed, 21 Aug 2013 17:49:25 +0800 Message-Id: <1377078565-22920-1-git-send-email-shaojie.sun@linaro.com> X-Mailer: git-send-email 1.7.9.5 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shaojie.sun@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 1. check clock rate is reported by hexadecimal or decimal. 2. clock rate is reported with interger instead of radix point, for example 1.1GHz must be shown in 1100MHz. Signed-off-by: Shaojie Sun --- clocks.c | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/clocks.c b/clocks.c index 203411a..b069547 100644 --- a/clocks.c +++ b/clocks.c @@ -78,27 +78,51 @@ static struct clock_info *clock_alloc(void) return ci; } +static inline bool is_hex_clock(uint rate) +{ + return rate%10; +} + static inline const char *clock_rate(uint *rate) { - uint r; + uint r, mod; + bool is_hex = is_hex_clock(*rate); /* GHZ */ - r = *rate >> 30; - if (r) { - *rate = r; - return "GHZ"; - } + if (is_hex) { + r = *rate >> 30; + mod = *rate&((1<<30)-1); + } else { + r = *rate / 1000000000; + mod = *rate % 1000000000; + } + if (r && !mod) { + *rate = r; + return "GHZ"; + } /* MHZ */ - r = *rate >> 20; - if (r) { + if (is_hex) { + r = *rate >> 20; + mod = *rate&((1<<20)-1); + } else { + r = *rate / 1000000; + mod = *rate % 1000000; + } + if (r && !mod) { *rate = r; return "MHZ"; } /* KHZ */ - r = *rate >> 10; - if (r) { + if (is_hex) { + r = *rate >> 10; + mod = *rate&((1<<10)-1); + } else { + r = *rate / 1000; + mod = *rate % 1000; + } + if (r && !mod) { *rate = r; return "KHZ"; }