From patchwork Fri Jan 20 07:17:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 644614 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp638293pvb; Thu, 19 Jan 2023 23:20:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXv7H9RIp3F69oqiJhhRuzwMNY8lb8Oo7LIxvosKsRqbN7BUw+re0H7DuZhodgYDI70nUlEv X-Received: by 2002:a05:6830:3747:b0:686:5e82:14b2 with SMTP id bm7-20020a056830374700b006865e8214b2mr4391994otb.10.1674199201416; Thu, 19 Jan 2023 23:20:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674199201; cv=none; d=google.com; s=arc-20160816; b=oFZ+4rS/r4JYarSUHhEB9MG4mjEcoGeWdCMwhSHGNJLcA6Qv9PeCty/YFfJK631LEo LjJMMUywO57N7l50i/Kjj1+Rf93gX02ocFidJGA+agu4fi3iurOzCeVkNkYMat3D/xOz FkpP37zetbXQY8Cfst0fNlSKJXQu8P86wATejXDbwZ3WFGAffzKfH9Gmvhr1RfAv5QNT npmHkID3FzpmfY/xY6X0pWTEoWiM0JOTDTohGOD2cbeQvVyQAZa6ZU2QU7h34MzWMF2t ShR1BzWI0p67wo7JbwbhtOiuXyaOpfDSMemwCoA0S016mrfp3/WQc25dXTVPM716V7KG Tx1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=H7l5e1Mk6NBap2n4RtHZEWgpKHTeaD3uETXTC3h5PBs=; b=Fyk4F7EbTDDBRWPZ2l8XtbdXIrpr/lSfwHtajewUWoizdww2QzUTyUz9jFmsjJInSi qVWHTAJY0ewsQluAE1V/4Um0pyRtTbF9pAIN9zDonYmnhChhh/s4HgM0Ii5hhdqyOgAx y48ECVMam4o9uefesQC7PUnF3nAg/ydYfF6OoqHAQ/4lH3aOGtINsQUGZ+FpZSunHikQ xPKOuluoxnrpUIh/H54bSomrwM0QFPfWxVytIzA+lMysE130hn5I6Gsr/CBUryaH49O9 6ON2A3cZSXKmXX8IrrWQcRKjkvq8HnmJOWtMwhDyWAA/HuMoAMPLNdmAdORUamVhqP9R I0vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c87J+4Fc; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id u18-20020a056808115200b0036ec8da8319si73079oiu.279.2023.01.19.23.20.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Jan 2023 23:20:01 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c87J+4Fc; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 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-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 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