From patchwork Fri Dec 20 03:50:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 3385671 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 328A3C0D4A for ; Fri, 20 Dec 2013 03:51:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 754C420127 for ; Fri, 20 Dec 2013 03:51:01 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2230820117 for ; Fri, 20 Dec 2013 03:51:00 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vtr71-0003Fh-VW; Fri, 20 Dec 2013 03:50:56 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vtr6z-00065V-Bp; Fri, 20 Dec 2013 03:50:53 +0000 Received: from mail-pd0-f175.google.com ([209.85.192.175]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vtr6v-00064n-Qp for linux-arm-kernel@lists.infradead.org; Fri, 20 Dec 2013 03:50:50 +0000 Received: by mail-pd0-f175.google.com with SMTP id w10so1970757pde.6 for ; Thu, 19 Dec 2013 19:50:26 -0800 (PST) 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; bh=p4u8H9QdIXfdjPx8yUOyLSnb0BFPtrFCArCLLmZjkqM=; b=SuP+DhMHUd9dfjzMtW8nJ29iMgY9kvFIdyOKTs+JH2qu7nDYWxGhFdBJi68AIVkMXE PAHqHPs/ROHYyu3ewnirrqQp0Oe++B5ws4Ji0PNX4YcTlo+kyXMl/Zi6F0CI/DzNMGEU zHVrpIY334F6awcmwqbMBi7TNDOLM2W3tjRUaI2N8tXO7eIMHOpkot7oKVGTJ15rHeTX Nvnfu6az0/DfWA1aP43eqmYIPH7itJhdaPgmBc7G5i9PfKmWoQq4yfhUNH02vKXKCeh4 zuPPnKnIbbNbR757BfKSe8g1pYQsS6aAQFHrMaH9Hb/Asn7sXNGn0uhyT5ldwK2Nc5dn 3AFQ== X-Gm-Message-State: ALoCoQk1EzW/HNEPvkyBtWZTyOpeNMGBH96EZHxh4ch80WoLpXLI0PxQwxXrwP73aKcCEzlAT2Hx X-Received: by 10.68.29.4 with SMTP id f4mr5825747pbh.85.1387511425474; Thu, 19 Dec 2013 19:50:25 -0800 (PST) Received: from localhost.localdomain ([140.206.182.114]) by mx.google.com with ESMTPSA id bh6sm14139338pad.20.2013.12.19.19.50.22 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 19 Dec 2013 19:50:24 -0800 (PST) From: Haojian Zhuang To: heiko@sntech.de, mturquette@linaro.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH RESEND] clk: divider: read before write for HIWORD mask Date: Fri, 20 Dec 2013 11:50:17 +0800 Message-Id: <1387511417-8573-1-git-send-email-haojian.zhuang@gmail.com> X-Mailer: git-send-email 1.8.3.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131219_225049_975697_64E78CD5 X-CRM114-Status: UNSURE ( 9.88 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) Cc: Haojian Zhuang X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When multiple dividers share one register, we need to read & mask register fist. Then we set the right value. For example, there're two mmc clock dividers shared in one registers. The clock register is HIWORD type. Signed-off-by: Haojian Zhuang --- drivers/clk/clk-divider.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c index 8d3009e..e1ea289 100644 --- a/drivers/clk/clk-divider.c +++ b/drivers/clk/clk-divider.c @@ -227,12 +227,10 @@ static int clk_divider_set_rate(struct clk_hw *hw, unsigned long rate, if (divider->lock) spin_lock_irqsave(divider->lock, flags); - if (divider->flags & CLK_DIVIDER_HIWORD_MASK) { - val = div_mask(divider) << (divider->shift + 16); - } else { - val = clk_readl(divider->reg); - val &= ~(div_mask(divider) << divider->shift); - } + val = clk_readl(divider->reg); + val &= ~(div_mask(divider) << divider->shift); + if (divider->flags & CLK_DIVIDER_HIWORD_MASK) + val |= div_mask(divider) << (divider->shift + 16); val |= value << divider->shift; clk_writel(val, divider->reg);