Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C2241C25B4E for ; Fri, 20 Jan 2023 07:20:00 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DA4A9856DD; Fri, 20 Jan 2023 08:18:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="c87J+4Fc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3FE88856A2; Fri, 20 Jan 2023 08:18:24 +0100 (CET) Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3B2B8856A1 for ; Fri, 20 Jan 2023 08:18:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sumit.garg@linaro.org Received: by mail-pj1-x1033.google.com with SMTP id u1-20020a17090a450100b0022936a63a21so8211434pjg.4 for ; Thu, 19 Jan 2023 23:18:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=H7l5e1Mk6NBap2n4RtHZEWgpKHTeaD3uETXTC3h5PBs=; b=c87J+4Fc1tWd1MC5zRL2ze+j6gWHq5v2vMuNactVJUX8taLdTu/ByJyo8G64xIHj4B IJ2215ymKgjoHsukgLmiB2a3rWg+2MmycrSvfs//OdJvc58cNQ0hePDgNnPzc6UD4+sb KN2Hb+wrGtJ93J10RKTMO56uV/lPOAUW/186xk27WcRSDTn+1o1n5cpFrn4Vv++6+YsU pBYgOvO6T9/3LsexSFLpWoQ/gtB+QZpLmeAPCftdItk+jJz1jdAbol8CfH/G7XpolGsI VrcpVHlcJUI6dUncCvxWC2/ujwQA/wf00IWXMRoC1LuPJkeNz/gKM07LS31qhKYsGzi7 //lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H7l5e1Mk6NBap2n4RtHZEWgpKHTeaD3uETXTC3h5PBs=; b=L0WWtm8dBDKawM9PFVjHyuxmFyZ8DBxYt9NknedmmOo1pPgn5GlBJrHRikby6MGrYN aowoyfS4/yDieG+Wm0Jr1FzcMqFZXS6meYRd1lElaHM7Au+eCZQO+ij2K6u15zpvF6aL hOP4xvdYEzJygKGAx2T0qetqBNcphVTe7vlHObye2OesM4fG4MjNSvcrnwrc1409wtMx 7pTxiVWpvY/dEM+BUfpHfyQyw1iDAL5/bprpn3CY2VhjGYjtxQO8Rc4E4yl79ZK7B0Tt DbLP8Zdp8AYj+joTSKF81zjkLWzahT1a3PXDQbhmxTEiZSi6tMPeao+YUy3Gj45eFTyK L35A== X-Gm-Message-State: AFqh2kp08ZzXflcG1BcKR9jB8ss6lX1suyUweT26LPWV/G/bGESNS2og PFQ9YmDlC/nk3gjf459a6qAY4bURh3rTT47d X-Google-Smtp-Source: AMrXdXsoUOuRtm3cDTbaiixB3sXOKhN0MpH7ntlJmuS6MOH9m1T+WrWwaq/ASf87sybBKsiK05GeKA== X-Received: by 2002:a05:6a20:6d02:b0:b6:9f9f:4b90 with SMTP id fv2-20020a056a206d0200b000b69f9f4b90mr29829923pzb.24.1674199098125; Thu, 19 Jan 2023 23:18:18 -0800 (PST) Received: from sumit-X1.. ([223.178.212.120]) by smtp.gmail.com with ESMTPSA id x15-20020aa7956f000000b0058bacd6c4e8sm9797586pfq.207.2023.01.19.23.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:18:17 -0800 (PST) From: Sumit Garg To: u-boot@lists.denx.de Cc: rfried.dev@gmail.com, hs@denx.de, joe.hershberger@ni.com, stephan@gerhold.net, mworsfold@impinj.com, lgillham@impinj.com, jbrennan@impinj.com, nicolas.dechesne@linaro.org, vinod.koul@linaro.org, daniel.thompson@linaro.org, Sumit Garg Subject: [PATCH 10/14] clock-snapdragon: Add clk_rcg_set_rate() with mnd_width=0 Date: Fri, 20 Jan 2023 12:47:15 +0530 Message-Id: <20230120071719.623661-11-sumit.garg@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230120071719.623661-1-sumit.garg@linaro.org> References: <20230120071719.623661-1-sumit.garg@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Add clk_rcg_set_rate() which allows to configure clocks without programming MND values. This is required for configuring I2C clocks on QCS404. Co-developed-by: Mike Worsfold Signed-off-by: Mike Worsfold Signed-off-by: Sumit Garg --- arch/arm/mach-snapdragon/clock-snapdragon.c | 24 +++++++++++++++++++++ arch/arm/mach-snapdragon/clock-snapdragon.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/arch/arm/mach-snapdragon/clock-snapdragon.c b/arch/arm/mach-snapdragon/clock-snapdragon.c index fda7098274..0ac45dce9a 100644 --- a/arch/arm/mach-snapdragon/clock-snapdragon.c +++ b/arch/arm/mach-snapdragon/clock-snapdragon.c @@ -111,6 +111,30 @@ void clk_rcg_set_rate_mnd(phys_addr_t base, const struct bcr_regs *regs, clk_bcr_update(base + regs->cmd_rcgr); } +/* root set rate for clocks with half integer and mnd_width=0 */ +void clk_rcg_set_rate(phys_addr_t base, const struct bcr_regs *regs, int div, + int source) +{ + u32 cfg; + + /* setup src select and divider */ + cfg = readl(base + regs->cfg_rcgr); + cfg &= ~CFG_MASK; + cfg |= source & CFG_CLK_SRC_MASK; /* Select clock source */ + + /* + * Set the divider; HW permits fraction dividers (+0.5), but + * for simplicity, we will support integers only + */ + if (div) + cfg |= (2 * div - 1) & CFG_DIVIDER_MASK; + + writel(cfg, base + regs->cfg_rcgr); /* Write new clock configuration */ + + /* Inform h/w to start using the new config. */ + clk_bcr_update(base + regs->cmd_rcgr); +} + static int msm_clk_probe(struct udevice *dev) { struct msm_clk_priv *priv = dev_get_priv(dev); diff --git a/arch/arm/mach-snapdragon/clock-snapdragon.h b/arch/arm/mach-snapdragon/clock-snapdragon.h index 2ac53b538d..c90bbefa58 100644 --- a/arch/arm/mach-snapdragon/clock-snapdragon.h +++ b/arch/arm/mach-snapdragon/clock-snapdragon.h @@ -42,5 +42,7 @@ void clk_enable_cbc(phys_addr_t cbcr); void clk_enable_vote_clk(phys_addr_t base, const struct vote_clk *vclk); void clk_rcg_set_rate_mnd(phys_addr_t base, const struct bcr_regs *regs, int div, int m, int n, int source); +void clk_rcg_set_rate(phys_addr_t base, const struct bcr_regs *regs, int div, + int source); #endif -- 2.34.1