From patchwork Wed Dec 11 01:29:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 3321741 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 902E09F37C for ; Wed, 11 Dec 2013 01:29:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D5CFD201B6 for ; Wed, 11 Dec 2013 01:29:50 +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 F0043201B4 for ; Wed, 11 Dec 2013 01:29:49 +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 1VqYcS-0005XG-Ua; Wed, 11 Dec 2013 01:29:45 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VqYcQ-0003yI-HZ; Wed, 11 Dec 2013 01:29:42 +0000 Received: from mail-pd0-f170.google.com ([209.85.192.170]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VqYcN-0003xT-NU for linux-arm-kernel@lists.infradead.org; Wed, 11 Dec 2013 01:29:40 +0000 Received: by mail-pd0-f170.google.com with SMTP id g10so8557150pdj.1 for ; Tue, 10 Dec 2013 17:29:17 -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=cKu0g1mR9Q8RdI6X+7PbdfgCYfcfkMtXANvEyDOjRPrAchcqBw/l/H7CfAv6vgd5wQ QrlGU3wXUgSb+me19stVBhHzW7lbcydg0HymjQI8l2TDbh22wn0oTHdiRHYSpixhX/H0 o+BgRzapxbSe+JfeGFxVkRmS37yK7085b2HXuUzBoTayTFu1C2bIe14Zfyriy2AME6vR TBwOxBX2jERvxmjh5+XPF9Y8J3btxOOkYSXZECUSfzJQuF4yzICQUU6AdlMWIimIpTjB vFLVz/dsI2Xyx6rBrVy15hSm8Ezr+yfwxXShOBlPQ6EJjxWrbvBF75wNB+kX5hcktUtz ZZNA== X-Gm-Message-State: ALoCoQmih3zN5OZzXgSlU4duPCykwhMt0zCjABbQ+uA3W9fM/6ILed9L3hP69i0RbDHy7wmIl16E X-Received: by 10.66.190.198 with SMTP id gs6mr31721382pac.49.1386725357032; Tue, 10 Dec 2013 17:29:17 -0800 (PST) Received: from localhost.localdomain ([140.206.182.114]) by mx.google.com with ESMTPSA id nn6sm28611258pbc.29.2013.12.10.17.29.14 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Dec 2013 17:29:16 -0800 (PST) From: Haojian Zhuang To: mturquette@linaro.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] clk: divider: read before write for HIWORD mask Date: Wed, 11 Dec 2013 09:29:07 +0800 Message-Id: <1386725347-14480-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-20131210_202939_832791_C8905E28 X-CRM114-Status: UNSURE ( 9.24 ) 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.4 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);