Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp171812pxx; Wed, 28 Oct 2020 01:31:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHd/kSHhPUm9DwJQprst1B4F88dUEt1qtM0+ibEMFVqQCVmmXZn8892VjDltpsiH+416lF X-Received: by 2002:a50:d805:: with SMTP id o5mr6610700edj.142.1603873902381; Wed, 28 Oct 2020 01:31:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603873902; cv=none; d=google.com; s=arc-20160816; b=GGfxVucwW6bjI17X/8qo3pf+x+hkUXuJuETiCt8VrWc9vHRqrMS4OjMlI/TG+AaFLr cVhhUDMCYdpoeGrNVkydCTP3nTq5RPTJeRl8STawbcSnZhIDELfpuDcwhOUPgkTUFX81 UT6ttGng7mZGZAl7wUD1XVTewUF3qKPLWMcjGxH/UUEAnqdUqbSlLQYwhCHrg1fBQjuh O5BOvl495tr/ahg/D4n5XQAPLgeLdMMT3oy/ZGWyDfvrT05FLp9z50FIv3LpsPjFndyQ 0RXbk5PZtdtPZpHH33zboz0jBt90/j0DwuQ8TS4BfUsGc5RsgSugN5X6hlKyXO5xfg6F rgQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xuJerIBBfiAdN7QyoHNS4BREGvTNB58m+qeO3Mgtnps=; b=AmK3m4jbv89wzFXW6BDzAB0Gkgd87HPXWq306ztrkzlyNu8zP6YXD4CT3o2AoZfjzi 7I6+QQlypXh7xm2mndlhc5bN86WrQStkCZMLikhMRyEycZKxBoqkYSYapQ2U30skTR95 H+SU2TvsHn/poXfQVfN3xLEtkA5duWJuQZc73nUaD8rpePO/u+SsKzo09rDZnvWmrBb/ xi9WT3XSLa6+ETAHDC9TXUjdmNFohQbHhwyu7LcaY7XPRIpiJLXaiuw0rWUpfHvlxNij J3pKT8PNXbebfjK9DdFsyspPIW9FveUR2B9Yobv6qIdtoW1Zf13/LBrwdV23U3+Ols81 KaZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OjW66NyH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gf17si2900638ejb.226.2020.10.28.01.31.20; Wed, 28 Oct 2020 01:31:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OjW66NyH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754426AbgJ0OF0 (ORCPT + 99 others); Tue, 27 Oct 2020 10:05:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:53418 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754331AbgJ0OFH (ORCPT ); Tue, 27 Oct 2020 10:05:07 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 07B7C22264; Tue, 27 Oct 2020 14:05:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807506; bh=MwScFoHCrD1FTWEgOOql8sERHWVfpoxY/zlARsLFSh0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OjW66NyH2L2TTTIQBUZvAtGyJQSpiIQwfxZTi4iuW8aIQ7UrBteQpnObA/nv+53nT XHGugXtFe0pFi8dhj+4/w6pFgmRRElOKI9/bfYY1dPH6WW7GX6XtQagXiJeoB3LHeR glMRel3dJuMqrEQrv7CfxwTr1jnw+5qUdibALSxA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Claudiu Beznea , Alexandre Belloni , Stephen Boyd , Sasha Levin Subject: [PATCH 4.9 078/139] clk: at91: clk-main: update key before writing AT91_CKGR_MOR Date: Tue, 27 Oct 2020 14:49:32 +0100 Message-Id: <20201027134905.835798683@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134902.130312227@linuxfoundation.org> References: <20201027134902.130312227@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Claudiu Beznea [ Upstream commit 85d071e7f19a6a9abf30476b90b3819642568756 ] SAMA5D2 datasheet specifies on chapter 33.22.8 (PMC Clock Generator Main Oscillator Register) that writing any value other than 0x37 on KEY field aborts the write operation. Use the key when selecting main clock parent. Fixes: 27cb1c2083373 ("clk: at91: rework main clk implementation") Signed-off-by: Claudiu Beznea Reviewed-by: Alexandre Belloni Link: https://lore.kernel.org/r/1598338751-20607-3-git-send-email-claudiu.beznea@microchip.com Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/at91/clk-main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c index 90988e7a5b47f..2e7da9b379d48 100644 --- a/drivers/clk/at91/clk-main.c +++ b/drivers/clk/at91/clk-main.c @@ -517,12 +517,17 @@ static int clk_sam9x5_main_set_parent(struct clk_hw *hw, u8 index) return -EINVAL; regmap_read(regmap, AT91_CKGR_MOR, &tmp); - tmp &= ~MOR_KEY_MASK; if (index && !(tmp & AT91_PMC_MOSCSEL)) - regmap_write(regmap, AT91_CKGR_MOR, tmp | AT91_PMC_MOSCSEL); + tmp = AT91_PMC_MOSCSEL; else if (!index && (tmp & AT91_PMC_MOSCSEL)) - regmap_write(regmap, AT91_CKGR_MOR, tmp & ~AT91_PMC_MOSCSEL); + tmp = 0; + else + return 0; + + regmap_update_bits(regmap, AT91_CKGR_MOR, + AT91_PMC_MOSCSEL | MOR_KEY_MASK, + tmp | AT91_PMC_KEY); while (!clk_sam9x5_main_ready(regmap)) cpu_relax(); -- 2.25.1