From patchwork Mon Feb 26 17:26:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 775912 Delivered-To: patch@linaro.org Received: by 2002:ab3:621a:0:b0:258:3251:9e33 with SMTP id w26csp1492917lte; Mon, 26 Feb 2024 09:27:41 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUKnyRGHK2LTKS0V0phIl5jdt5EiZ9Rp2QBunYCOi+s5OnDJPibCyDIiPKDmfTNXKBemD4ne/ZdSdbrWexE00Jh X-Google-Smtp-Source: AGHT+IH268g3aAK4HVIZ1jy2F1bsa4vxiCIlx7U+FoRWSELooA3hKoYW/8adlyakGN9o83UYXJe8 X-Received: by 2002:a05:600c:6b07:b0:412:117d:949c with SMTP id jn7-20020a05600c6b0700b00412117d949cmr7221933wmb.41.1708968461196; Mon, 26 Feb 2024 09:27:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708968461; cv=none; d=google.com; s=arc-20160816; b=pvYBeU8wJERwFmajuAGkB8MQK183U39+7jdY5uqhf3JoSEVQSc9UTLlGRTQ4XUlr1Z s6gai5kZ9H27DwClnQHvDEOp2S+ZXWx7Y1XxMsnD4IFBhkWUrsQtFCkzcRlujnSLuoPW eubBrJZ52Hld/U2AhDgD6fXJwYAE3vqc1/PH4gw+gzXYull6tEf41+5LyBSZtoWi5UFG pMdZKrgrwkQNq98ALqyhAQHq9lGH/eknYV8P5QL2Kx4yG/h6RmGHvXNR9L91mJwRT62c QXKKjaHg4B70P3/twh+czEqaOk2B7g0yG9S9H2e3toLuGienwynd5+VIUHyQaxbacTuk haxw== 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:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=IPC/7S3FE0TL++yPkLkVnL3GlOOYKaK7mUzqm0pkkkI=; fh=Qmo3/I40z2Ri/BEh3tCKqTaqa7VOXQ43ASPAopsK+c0=; b=rh4h4rtDaicEyykeWoiw6kvxS0Eg+8bZGNsud+1oMYA1vqaIKGq6IBFkky6SMgxcSj 9PVjyyzhRfNmLr4oePP/noRWGdb7+0036rdWKZrFAzKH7ONtN1ptJP5Qi1BwRyMxgsO3 34uF/D4vF72WGhXfBAvMMPPy2Shb9VfMfT0xvn8HfiQy+XhSGiNfp39Ftv7gjXvUECAv RbNBB28K9FvjeJU17WW2Xsj7IaM8y8wK4wjSIBzenay2aYDz91WwQvzEBXKoqrmyjNKL gHq3peM5SaCbdBQ/7nbTdrN0jRp17s9RwJVONhUStDD/KQME3cj4nxJ57ZhaXAzglcLU yzVQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LsgZS5bB; 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 u16-20020a05600c139000b0041282be7145si4079211wmf.79.2024.02.26.09.27.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:27:41 -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=LsgZS5bB; 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 9F30187F91; Mon, 26 Feb 2024 18:26:36 +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="LsgZS5bB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E836887F85; Mon, 26 Feb 2024 18:26:34 +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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) (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 6EFD387F23 for ; Mon, 26 Feb 2024 18:26:28 +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=caleb.connolly@linaro.org Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-33d6fe64a9bso2643252f8f.0 for ; Mon, 26 Feb 2024 09:26:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708968388; x=1709573188; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=IPC/7S3FE0TL++yPkLkVnL3GlOOYKaK7mUzqm0pkkkI=; b=LsgZS5bBCkPw0eIawmImo0AOpHSOY8Mgblfu1KYc/7n7PiwTgu/OI3WtydyzBTZlSW iFEgT5etfgzuoX7OQ+geQRoUQT3kWo1v3A17wmyzSbG/818rmbQXA/zynw4q8Z2UfdhE 0FgFMybun9I082dy1Yd9IJJf8hwLJXQ5ixOLPuwHvgArEINa2XKurkmDXIjs5/ALjMoj qudv4VtfZTXnLyzOIcPki17E60JM+1CGsio/pDq8GjJgrCcHT7jokhrFkj0loq4f8CgN Wk+Icp74+60eKFDMvT8jLNxReM7ddmYP0Cgb6PNysz4X3oZqfxf7QjFuJTLlC6Dz0DyJ /g4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708968388; x=1709573188; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IPC/7S3FE0TL++yPkLkVnL3GlOOYKaK7mUzqm0pkkkI=; b=khst8/SULb7TOwJv2trK1XNC9w9b5yKWZWKyMNDYn6hkSAMSxUqCUs7S3upgqO6oHI +U6FAx1m8i1VZh1d+Byc7IUcALLoqLPZyzslYsyChFgbvaiGLaRo7X5KDb8rwuJBnF6O 863zv3xO2JpRPWp0iePq9iAkx4ndcKLMHjjU2iKo95zPQBWbQEPT/Q2Y3qst3DQ4qwb8 QUrBaNzclFI7YVY9hDYTLz0SaJvDtK1nQuvOTlWoI2ru88Kk4dPsAtxvHLyRiAm8IQdu w9zEycHbUNdbpIzO3szbUjWmDORJmoPMS3BimU73cEpX+sW+tNcoMXbUN5NR48yOX4e2 nDtw== X-Forwarded-Encrypted: i=1; AJvYcCW2C/4sxKznpgIDzYcAHgqHi3Jem8Oc8SYcLUSzA0VlmbTEG3T4wBmYxraJgdA8mqtNzUPA5jI/RbiDwxEMGIUEYBSWrw== X-Gm-Message-State: AOJu0YzzSV+l3yi9Py63VYq2k0W25MCv4Wizh4oX30Q7J0jtyk8rqOaT MiIjvI2wqBKULRM6HiS053mI4jV8PSZaWL5Er1ucfGtUAB6xku3b0c1dvOjWnfI= X-Received: by 2002:adf:f78d:0:b0:33d:1656:21fa with SMTP id q13-20020adff78d000000b0033d165621famr6419132wrp.24.1708968387939; Mon, 26 Feb 2024 09:26:27 -0800 (PST) Received: from lion.localdomain (host-92-17-96-232.as13285.net. [92.17.96.232]) by smtp.gmail.com with ESMTPSA id bt1-20020a056000080100b0033d9c7eb63csm9142256wrb.84.2024.02.26.09.26.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:26:27 -0800 (PST) From: Caleb Connolly Date: Mon, 26 Feb 2024 17:26:10 +0000 Subject: [PATCH v5 06/39] clock/qcom: qcs404: fix clk_set_rate MIME-Version: 1.0 Message-Id: <20240226-b4-qcom-common-target-v5-6-10c8e078befb@linaro.org> References: <20240226-b4-qcom-common-target-v5-0-10c8e078befb@linaro.org> In-Reply-To: <20240226-b4-qcom-common-target-v5-0-10c8e078befb@linaro.org> To: Neil Armstrong , Sumit Garg , Ramon Fried , Dzmitry Sankouski , Caleb Connolly , Peng Fan , Jaehoon Chung , Rayagonda Kokatanur , Lukasz Majewski , Sean Anderson , Jorge Ramirez-Ortiz , Stephan Gerhold Cc: Marek Vasut , u-boot@lists.denx.de X-Mailer: b4 0.13-dev-4bd13 X-Developer-Signature: v=1; a=openpgp-sha256; l=2816; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=T09SWNq7zmrZW/dvXhLpaVLY4zl1q1d3kGQjbkThN9M=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtQ7J3fOSTn/ZWeEdsvHptnZK//NDTafU9E472ww07HYi PL+jmPrOkpZGAQ5GGTFFFnETyyzbFp72V5j+4ILMHNYmUCGMHBxCsBEplxn+CvTv3gy57X6zUZB M2aFHt410eprcMl93ti/7UU6f+fN3HKL4Z/topWrijqrOi4FnjV5OcuBn5mnISXZ5q7wbk4Nt83 rNu4BAA== X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 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.8 at phobos.denx.de X-Virus-Status: Clean We should be returning the rate that we set the clock to, drivers like MMC rely on this. So fix it. Reviewed-by: Neil Armstrong Reviewed-by: Sumit Garg Tested-by: Sumit Garg #qcs404 Signed-off-by: Caleb Connolly --- drivers/clk/qcom/clock-qcs404.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/clk/qcom/clock-qcs404.c b/drivers/clk/qcom/clock-qcs404.c index f5b352803927..958312b88842 100644 --- a/drivers/clk/qcom/clock-qcs404.c +++ b/drivers/clk/qcom/clock-qcs404.c @@ -192,26 +192,20 @@ static ulong qcs404_clk_set_rate(struct clk *clk, ulong rate) struct msm_clk_priv *priv = dev_get_priv(clk->dev); switch (clk->id) { case GCC_BLSP1_UART2_APPS_CLK: - /* UART: 115200 */ + /* UART: 1843200Hz for a fixed 115200 baudrate (19200000 * (12/125)) */ clk_rcg_set_rate_mnd(priv->base, &uart2_regs, 0, 12, 125, CFG_CLK_SRC_CXO, 16); clk_enable_cbc(priv->base + BLSP1_UART2_APPS_CBCR); - break; - case GCC_BLSP1_AHB_CLK: - clk_enable_vote_clk(priv->base, &gcc_blsp1_ahb_clk); - break; + return 1843200; case GCC_SDCC1_APPS_CLK: /* SDCC1: 200MHz */ clk_rcg_set_rate_mnd(priv->base, &sdc_regs, 7, 0, 0, CFG_CLK_SRC_GPLL0, 8); clk_enable_gpll0(priv->base, &gpll0_vote_clk); clk_enable_cbc(priv->base + SDCC_APPS_CBCR(1)); - break; - case GCC_SDCC1_AHB_CLK: - clk_enable_cbc(priv->base + SDCC_AHB_CBCR(1)); - break; + return rate; case GCC_ETH_RGMII_CLK: if (rate == 250000000) clk_rcg_set_rate_mnd(priv->base, &emac_regs, 3, 0, 0, CFG_CLK_SRC_GPLL1, 8); @@ -223,13 +217,17 @@ static ulong qcs404_clk_set_rate(struct clk *clk, ulong rate) CFG_CLK_SRC_GPLL1, 8); else if (rate == 5000000) clk_rcg_set_rate_mnd(priv->base, &emac_regs, 3, 1, 50, CFG_CLK_SRC_GPLL1, 8); - break; - default: - return 0; + return rate; } + /* There is a bug only seeming to affect this board where the MMC driver somehow calls + * clk_set_rate() on a clock with id 0 which is associated with the qcom_clk device. + * The only clock with ID 0 is the xo_board clock which should not be associated with + * this device... + */ + log_debug("Unknown clock id %ld\n", clk->id); return 0; } static int qcs404_clk_enable(struct clk *clk) @@ -304,8 +302,11 @@ static int qcs404_clk_enable(struct clk *clk) clk_enable_cbc(priv->base + BLSP1_QUP4_I2C_APPS_CBCR); clk_rcg_set_rate(priv->base, &blsp1_qup4_i2c_apps_regs, 0, CFG_CLK_SRC_CXO); break; + case GCC_SDCC1_AHB_CLK: + clk_enable_cbc(priv->base + SDCC_AHB_CBCR(1)); + break; default: return 0; }