From patchwork Mon Apr 15 15:03:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 788972 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp1953234wrm; Mon, 15 Apr 2024 08:04:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW/sutsb/QLbnDSOfi6hdilJ3P/wbzCwwBKPVSydjmBDDbKP1Be4souWWRMz0VwfdE/Bt+C8hVnmKFJw7YqLGNl X-Google-Smtp-Source: AGHT+IEpi9UBZpgeYqovFj+yJfQvn9gyeuvTSB1hxkzFmkQquIELnRjRvgCUTZDwcYQTWRo4dGj7 X-Received: by 2002:a17:907:360d:b0:a52:5925:1f76 with SMTP id bk13-20020a170907360d00b00a5259251f76mr3487127ejc.47.1713193441174; Mon, 15 Apr 2024 08:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713193441; cv=none; d=google.com; s=arc-20160816; b=ixZ3JE3cbPx0tOTE9U0OXbjFD7yt0kqz82ig6Dt8EagcvsHSuLHIQMx/Y2E+pUjUqz NzAu5xFWziMLidy3FfLz5vfgvvoTNBpEA4vfTH1aJv6SABX+ZDWNVo1QYzsLLEw3PWz1 l57aAcCcoFGWdiq2NCK114zCe22XQPjqTSaBIeP9dZSWKSRUGWE7VROEgrADdux1pR6h 6Z3p+0Kd/KLFdXTGvwzKgyiUOoSorm0cvt1W2CCzNu6wFlsxUP2G/BvvLl9BTUt2Xw00 0pVrS9t20TgzXgl2z3ZjEvLh5f7/HIUHRLxbJgFHUGNwx1M4kXZLIdsGh+VMEFVCuIyy NOGw== 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=h/blv1jhNMGdp3y04vVVIazZY+yEsnljwxhnc5rTng0=; fh=29KVoMVZWPLZzIgZgB8f6WXCsf2Dk2IDj/nmwZ/7DGU=; b=ESbgcy7rspjr54qq1YqP6y06CQjZnjpLJpXZVbJLwt3Fw8bXVwspN7C9FghqpJq+JA 8UxBbLyXuoJOw1vbhHJnILlmbK1nzPvwKAkJpSvFMf3NtDPryXxO8cuOWJ4pOCkYUoIQ 0YahHvFqOk5oUmw5vDY2eJLuUIS8ckulxIx2PqcFkF4A6irkFInAH3NdFzMbBTfPpWkA 1hIIrY4kec1N+daRyBjZKu3XlInkrNe1fEoXJOfCsck7/yEcqCRdqMYtChuQjwG1DQX1 XAwYL6U6GGbxesg8EGYaMtHdv+zDyInNuhrY+YzU/UD3E3RmXc46PRt8d9l2f/eZJcZ+ isug==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d3E1HwBu; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id qw42-20020a1709066a2a00b00a466b217280si4873913ejc.759.2024.04.15.08.04.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 08:04:01 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d3E1HwBu; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 5499A87CF2; Mon, 15 Apr 2024 17:03:50 +0200 (CEST) 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="d3E1HwBu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 93D558814A; Mon, 15 Apr 2024 17:03:49 +0200 (CEST) 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=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) (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 893FC87CF2 for ; Mon, 15 Apr 2024 17:03:42 +0200 (CEST) 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-lj1-x236.google.com with SMTP id 38308e7fff4ca-2d895e2c6efso42316531fa.0 for ; Mon, 15 Apr 2024 08:03:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713193422; x=1713798222; 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=h/blv1jhNMGdp3y04vVVIazZY+yEsnljwxhnc5rTng0=; b=d3E1HwBu1ejDKeEsmh4Zz8TspG6aK4qtstpEnVotmPBok/iW1GsT/L0FACczssSEB4 Mf8OxWiKnlrUIN4tCM7UcoopPTb68iiX8AuoSRIhCPcYUKhPkR5Zj6mWWFlghZmGo4VS ADeBIPaCv8tNIWZlBD7HxU2kQsnJX2/bLdrAYFQqNT9/bu4sqSiJpGO9ncHzbBRR55Ig C7cLtVidIxQxRpA/Lhx3UP5wA/g4FkSpdwitdq3zQjO48y6omb8gZzoIIxFdg29Dk99f 7XRZE4LNgC9Bs14VHdrlcza+OsDnZI+uCRGmldC0OkZvXz4lSNgHHaPqMbLtofr+GhM9 BB+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713193422; x=1713798222; 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=h/blv1jhNMGdp3y04vVVIazZY+yEsnljwxhnc5rTng0=; b=O+YQxgnFbycYk6nL4aGFbP/giWunwWsgeAQx6UDZZN+N6Z//QrzPccFgyG49X3wfCC 3zGnVubZomONqukLSCZ88mQfR4/G8JlFr3rPwaL42H/1D8MtcWTuMsQqYH1EC4eS0owk L5F++/lVVCngxTPorDLNzKGT45VuVYsF//a71cF1k5Ir4+VfOuKMNTX2TqtgDfu6aiHA q/SBE8GClY4X1tT0bpsW/TAtzvzRjm14szZctqo1q+4TqksgiX8JcR18smzkMFygaMd+ erLB7Qk9Su4wyGuu4ZlT2oqPS8mMWeQjkFz5fJCaDdAqr3jHJ99noJ5iI/SOmhe48TZA kQLA== X-Forwarded-Encrypted: i=1; AJvYcCWL3cv38xJdwFRRw9uvdDsrD4zQQDnSmLM4UoNg9CUndAkAbrRu0qFYYom4w6ztx4ui4gt/dR8oXW3WzKUEkqVKUedSHw== X-Gm-Message-State: AOJu0Yy1xq1me2+caEY6HUiBVZh421O4LKdgwpFxWTi9S6Eq9nDkdEuU bueE7cGjXqdVvlPyatzBmV+Wv6ocFfzU0YnMZi5xTff0hhOYyfLfOWkcEzDoXgI= X-Received: by 2002:a2e:3509:0:b0:2d6:c0eb:41cb with SMTP id z9-20020a2e3509000000b002d6c0eb41cbmr6690843ljz.3.1713193421910; Mon, 15 Apr 2024 08:03:41 -0700 (PDT) Received: from lion.localdomain (host-92-17-96-232.as13285.net. [92.17.96.232]) by smtp.gmail.com with ESMTPSA id p7-20020a05600c358700b004182cd07133sm9040333wmq.3.2024.04.15.08.03.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 08:03:41 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Apr 2024 16:03:38 +0100 Subject: [PATCH v2 1/3] clk/qcom: apq8016: return valid rate when setting UART clock MIME-Version: 1.0 Message-Id: <20240415-b4-msm-serial-bitrate-v2-1-b7a048adc6a3@linaro.org> References: <20240415-b4-msm-serial-bitrate-v2-0-b7a048adc6a3@linaro.org> In-Reply-To: <20240415-b4-msm-serial-bitrate-v2-0-b7a048adc6a3@linaro.org> To: Lukasz Majewski , Sean Anderson , Caleb Connolly , Neil Armstrong , Sumit Garg , Tom Rini Cc: Robert Marko , u-boot-qcom@groups.io, u-boot@lists.denx.de X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=920; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=z+mdt6z8O9e9zBFdjcbWdLQu5FVirlaHaG+3os0axxg=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhjRZx9PP9dzPvHjak6Gpu/CN/aZNE3+9K2oN6dz7/6lUa 1HmxRsrOkpZGAQ5GGTFFFnETyyzbFp72V5j+4ILMHNYmUCGMHBxCsBEOpYzMuw6Gh1k/VHH7X3O 04trdnwy6Wq4+HRu/0wXpz2Hg1umTHvD8N/r3H9hzQn/2txCP3x6abz46+MuzoTyvy861eq27GN 6kKcIAA== 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 The clk_init_uart() helper always returns 0, but we're meant to return a real clock rate. Given that we hardcode 115200 baud, just return the clock rate that we set. Signed-off-by: Caleb Connolly --- drivers/clk/qcom/clock-apq8016.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/clk/qcom/clock-apq8016.c b/drivers/clk/qcom/clock-apq8016.c index 5a5868169c89..6210fba87984 100644 --- a/drivers/clk/qcom/clock-apq8016.c +++ b/drivers/clk/qcom/clock-apq8016.c @@ -99,10 +99,10 @@ static ulong apq8016_clk_set_rate(struct clk *clk, ulong rate) case GCC_SDCC2_APPS_CLK: /* SDC2 */ return clk_init_sdc(priv, 1, rate); break; case GCC_BLSP1_UART2_APPS_CLK: /* UART2 */ - return apq8016_clk_init_uart(priv->base); - break; + apq8016_clk_init_uart(priv->base); + return 7372800; default: return 0; } } From patchwork Mon Apr 15 15:03:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 788973 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp1953389wrm; Mon, 15 Apr 2024 08:04:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUd8GPHa3uhiIVveLMP0lxb+RI9+S11dM+A5ZLs6ihJ3FOtpZoezdNSM6CXs03vP6pWibSm6BvpIurS4WmHUx+q X-Google-Smtp-Source: AGHT+IHeaqokBDvBRzOTR9Jk0A9dD6IRXtB9DTtQ2weqVYGosogFEtb90ch2xDLbtq3jw1zo4UN/ X-Received: by 2002:a17:906:4fce:b0:a47:20c3:7c51 with SMTP id i14-20020a1709064fce00b00a4720c37c51mr7790314ejw.71.1713193452885; Mon, 15 Apr 2024 08:04:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713193452; cv=none; d=google.com; s=arc-20160816; b=hHoV6OO7vsGmJUU+lx4nkPZKLy3gwnCcy01mtMkiwmvOn0W7XcLemzMOVP8SVIwKjJ vnM6jNDkS20rWPy1pklYbzHRKDmsoeRvF16zoK2n0hfSATHhI91DzMrWaEopzk60SHYV FqE7sGcfBiK9y1rOLIAnCPvgoJzgdANddt1Y9RoTthB5hfvrPBSj6/TeGihN17vZuDjQ ne5JOMB6K0zrXZ68CvDKM0EFOrAchLz+vqRibowIVolvWTaAXHlxFsrXqdwiG63cEAYe F1uuTtbpIi5OGVE8+Rvr6WxG6u6+lfkLLazzmdzEepuZCSgIT6NvwEmEnvGXcdantdMw VqbA== 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=75JeNrH2fm9Dj7m4XrOpiemG5n9ITOmRPsU5m9vbyek=; fh=Ge6gtez/3o7cfVs50sD/rBJxgeDgl7V1gk1oxphBl9M=; b=QBCTdAY0Rp5WU4dZaKA2wL774mIsgXLE398VdkBJ6KAHs+x7eFvNPr0AtusmRFm7FR 5ksUxBerY/3/fF36qHAcLTCy2OgcyUMgioIgyEkZxeasg9CBF1csJf9rTe6eoTXnsY7a uL5dggDZPs/Uyvkb6P67RU4i6d8vRHYq9xE6kgXKZWnV+R0V81mQCqn6FV/2iPXnqcrZ 1/KYUZoiRk/EpkQCYfz0UKGNW5fvAXATKylQyqJbPgO0g3cc00g524E32H1Y1l3Jwddy gbufJINM/Vc9LxsoJsgwKb1F4IFKvDzclfh7OgYjA4fYrqKFYg6oo+o6l4jTXBJGBP6k rbBQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dcW09vw4; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id k27-20020a1709063e1b00b00a51ace5e988si4750756eji.875.2024.04.15.08.04.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 08:04:12 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dcW09vw4; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 D3EB787D57; Mon, 15 Apr 2024 17:03:51 +0200 (CEST) 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="dcW09vw4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3658287CF2; Mon, 15 Apr 2024 17:03:50 +0200 (CEST) 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=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (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 9493487E3F for ; Mon, 15 Apr 2024 17:03:43 +0200 (CEST) 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-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4187a98705cso3295165e9.2 for ; Mon, 15 Apr 2024 08:03:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713193423; x=1713798223; 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=75JeNrH2fm9Dj7m4XrOpiemG5n9ITOmRPsU5m9vbyek=; b=dcW09vw4dmIpKNWzdWxz6AQKjjZLagh7dukPJzPQ0hpHEGImQT93DuCL1Ucp7k3SKN 7pkHQwDQDaxwDTlWszcsxu6ZsIAdw7b7Tfv7U7Pw17cdzsEIk7pA5FoI/pAoeU1XzPdi H0n2KAWJyqlCrTybPm1cGFM3t7xfMSLVmLJuyIjAYxdaJ1J6W56rMRBMMtOCOXSzicjZ vEcgsIQVLwXamBIRClrwLlvfEg5o06WR6xnQhGxzVHDQHDRkalSuwVg3zHbI4kcVPg6X 2EpBbmkCtqEs/JrxnoUSkK4h+5soazubhe+d4YZCpyNxa9YWkRIFmbqaFcXjnSep5+tQ eaaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713193423; x=1713798223; 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=75JeNrH2fm9Dj7m4XrOpiemG5n9ITOmRPsU5m9vbyek=; b=kVCi07zs6pf3C0Lm1kKh8XcjL/IXbptYNc7x3gTLAApYCrGfVOwB4XbVgUEHTKJvVg /LWcq85MWZb+JTLF/H9A0JrbrgzZ0P1LB+5l4EebqHZNRYUdcugWecPr2wyhT5j/CPvv XnlfFQg1r1/blXUXuyfhb1LA+vWs5bYuyItfwmNz7PCLsw0yli5nav7lJVBZhRRfRfuw xYhtnWzzCv0R2OIxthy1Y36UmfGpNWA4Yj28W94bxbVjjFx3kceuX9WyVkyBvhbL2RBL dJZwNbX4AE6rQ46SSEeQhvXII+0xC0uNJ13s0gm6tIPy7QwOftCP2FbBSdkrpQZKR92z JF5A== X-Forwarded-Encrypted: i=1; AJvYcCVdziQ4pD00hpQ9eHGlEyTuft1iDbYbNOGmekB6hqH88Ial4sdhHj87iCmr2dvQoyfdfH41QhPUzs88pyaH2AMA7rhrVw== X-Gm-Message-State: AOJu0YzXUFrLspFgwni31UJdzu/jGg1rle9YnLgBE5gIm/dpdgDHhYGO HDUHIDw50kYY7vJV93EoC9XJ+TNnYTUau8ACzSgy/9VKGZPwyG2vHIYzCQW4YAg= X-Received: by 2002:a05:600c:4689:b0:418:4ecb:fc80 with SMTP id p9-20020a05600c468900b004184ecbfc80mr2335105wmo.23.1713193422789; Mon, 15 Apr 2024 08:03:42 -0700 (PDT) Received: from lion.localdomain (host-92-17-96-232.as13285.net. [92.17.96.232]) by smtp.gmail.com with ESMTPSA id p7-20020a05600c358700b004182cd07133sm9040333wmq.3.2024.04.15.08.03.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 08:03:42 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Apr 2024 16:03:39 +0100 Subject: [PATCH v2 2/3] clk/qcom: ipq4019: return valid rate when setting UART clock MIME-Version: 1.0 Message-Id: <20240415-b4-msm-serial-bitrate-v2-2-b7a048adc6a3@linaro.org> References: <20240415-b4-msm-serial-bitrate-v2-0-b7a048adc6a3@linaro.org> In-Reply-To: <20240415-b4-msm-serial-bitrate-v2-0-b7a048adc6a3@linaro.org> To: Lukasz Majewski , Sean Anderson , Caleb Connolly , Neil Armstrong , Sumit Garg , Tom Rini Cc: Robert Marko , u-boot-qcom@groups.io, u-boot@lists.denx.de X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=979; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=jbE4uxM05hys6K6aPZcowyfpb9rgLC2loD8Pu1qX1Mc=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhjRZx9M3F256+5Wh45rBuoxbjiniNZxzj3/es3zz5f0MQ WUNTjIhHaUsDIIcDLJiiiziJ5ZZNq29bK+xfcEFmDmsTCBDGLg4BWAit/4wMsz4O8/v3Ncg0aeJ Emtc+makL1De+ujl54iDmT8Z2j8U2HAy/OFo+R3v1/li2gMGy+319r5d8XNLzjRaBBxPEw1s5T6 kNBkA 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 clk_set_rate() should return the clock rate that was set. The IPQ4019 clock driver doesn't set any rates yet but it should still return the expected value so that drivers can work properly. For a baud rate of 115200 with an expected bit clock divisor of 16, the clock rate should be 1843200 so return that frequency. Signed-off-by: Caleb Connolly --- drivers/clk/qcom/clock-ipq4019.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/qcom/clock-ipq4019.c b/drivers/clk/qcom/clock-ipq4019.c index d693776d339d..72f235eab212 100644 --- a/drivers/clk/qcom/clock-ipq4019.c +++ b/drivers/clk/qcom/clock-ipq4019.c @@ -20,9 +20,9 @@ static ulong ipq4019_clk_set_rate(struct clk *clk, ulong rate) { switch (clk->id) { case GCC_BLSP1_UART1_APPS_CLK: /*UART1*/ /* This clock is already initialized by SBL1 */ - return 0; + return 1843200; default: return -EINVAL; } } From patchwork Mon Apr 15 15:03:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 788974 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp1953562wrm; Mon, 15 Apr 2024 08:04:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXK2SfyW1OfcVuh6A7+rjYykLFshRI47vSwFZWrzMvujzObxGQSl9nM/sBy99FgrxI/3vLl79Y4e1WOH9EZdxlS X-Google-Smtp-Source: AGHT+IHWkbIcm92uH1HVlY7YZQ2IU72aqO5OhXKPsc/1udD2M9z/RJPHGYbrm6UruNt1Bl18M25d X-Received: by 2002:a17:906:e0c7:b0:a52:5df1:84b7 with SMTP id gl7-20020a170906e0c700b00a525df184b7mr2530946ejb.10.1713193465159; Mon, 15 Apr 2024 08:04:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713193465; cv=none; d=google.com; s=arc-20160816; b=iXIr0pDMiwru5ocfEmbHknEOzfcc0A3x6qVaPIgEPEbQF9dV/NSOfN/7JG6cguf68q qjwS/APCslHjhSrOmmP7jO23PQ0XuqwTExgub6moLiJyVWZ45IwNVFJriNPTOg6qPmjx 5H7eiQYlaUanXrXdNorYixeXOalZA02tYIp+W/f7XZ+ihLbFklwXOqEkFdfmpLTkGpQl Qatfz+zdtqPZdlOWs8g/hRl50T2GjzGy7coLOMQkvr9hHxtajU+4rTwmeeOt4zngMnue VTsHpMF3Uue2gKmuzmDm3mwu1jaW/d9w0gNpKuww6BbcCrnsit8+mcTYfgQ07KTQK0sm ENDw== 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=phiE3Uf7uCQ3Nfz23xgWKVkALYZFNegIdrJA5Svb6VI=; fh=UwJJfe9/DEvA8NkCvQQS7LmLS1ENzVznXVvZPVUZl+c=; b=T/lh/JtQHVVvmOW5WD6/XwR5ILZm7gsntOizGm9+CDNNb7AMvccevzRU0KuMuPTwNh iXoEuG/HisrrZFx7+N+P4X8LcA0fayRwwVVQmwQ/nr0HuWqw/P2mFQzBqOqn0pRD7oWL KQchYz9oYayycZh2Lj+r87/HbfoWK+uUATmQLTbksI4QfeR3G8uIFeVyxqs8zhhCl4sH vWPXEt32DMtucCGapH8hKXU775lHEX37Vzu++1kWK+2+lLWqBk0FUNx6NwKZgSBIQKFT KmfWWqI1xlzgjZW12skwGrG/YPPODMLFOycZjF8sTdRIOJYVtIaK7wmHYHjpkQXWHsn2 4KZw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KpMZvJ2W; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id rs28-20020a170907037c00b00a51a67eeec9si4695209ejb.950.2024.04.15.08.04.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 08:04:25 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KpMZvJ2W; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 3E22688167; Mon, 15 Apr 2024 17:03:52 +0200 (CEST) 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="KpMZvJ2W"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7B66787D55; Mon, 15 Apr 2024 17:03:50 +0200 (CEST) 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=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) (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 B88B68786C for ; Mon, 15 Apr 2024 17:03:44 +0200 (CEST) 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-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2d718ee7344so32786451fa.2 for ; Mon, 15 Apr 2024 08:03:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713193424; x=1713798224; 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=phiE3Uf7uCQ3Nfz23xgWKVkALYZFNegIdrJA5Svb6VI=; b=KpMZvJ2WQsUzXl+EQ1YwbNSzTgAuaNpB6BG7qrG8vLMa/4UyQlPhliZLkkin0JzGYk MiAeymZt+vDU8YPsBLRP/uPuBfRmv68rqvVx+z9dnMV5gZjhqyAJkHnCBBYxv689Azlv kgHVbr/xLz0ZsY6WpT+1UQdXVnN/aUUIxDr7qN3+lyG/uSv+lN4VII3fcN2E/UV7UCqd VyBub/fCQUEvDN+RZEDpzZ3snMnvOHYHsdtmSob9WSqU8FTFhx8ruuoTmT5nw2CSsO1b v6lIpal+vu6ad2ZEguMzzP255wJAWF8kFDRcmp4PM3VrO76LDSfhEsE7+Npgc6X4KKjm P4og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713193424; x=1713798224; 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=phiE3Uf7uCQ3Nfz23xgWKVkALYZFNegIdrJA5Svb6VI=; b=e5hD0HtJoGee/QoMeYS3pVv4C2rknswfNAb2kQxkXYjtE5yGrmzecDL7o5FBwmUkS3 Rk7I8bStntpT1Au2EI19ceWWDIMRN5r8r+5qAO5MfQPGcsumw7us5LlfWsV6t/WSHeKO mfSwWgu7pu/9dl3KEbPRuVSdoECEUH1aSVWgBy41VqmbTxW5C9MhsrjYdsasPn2Ax8WP ou8u9Axvg+rOAA/R/1XfKP8dFc9ONueQ93sp0hJhwYbmT86Kx9KYBCgq9b32feogISt5 4IR+190zbCtVhxPISAqMSKfjm4OFiJmOPaAh5tD14pXKXxRzpIVNg5bPxyy4G2uUAd07 mxPw== X-Forwarded-Encrypted: i=1; AJvYcCXGzc+3QN6SdNSFGPj+StiboTN7N2ajp+D5gPA/mbqAoyp6pj2lJrpiajb1yw5SqtIx3zEVFI6iSCtuP1bDGVJNyKitlg== X-Gm-Message-State: AOJu0YxYUf3Cn8vRCy4i4S1K3jLnwiwW4FhPdKLnxSA5uXnZrCaEh7CG KW6VXj5XsSoQJ/ctV8gUAQz5N5fRSSPBoPyh0RdgTLyuUzxkBJPzVJfnwnWyIRw= X-Received: by 2002:a05:651c:19a2:b0:2d8:36f3:663f with SMTP id bx34-20020a05651c19a200b002d836f3663fmr7736178ljb.31.1713193423842; Mon, 15 Apr 2024 08:03:43 -0700 (PDT) Received: from lion.localdomain (host-92-17-96-232.as13285.net. [92.17.96.232]) by smtp.gmail.com with ESMTPSA id p7-20020a05600c358700b004182cd07133sm9040333wmq.3.2024.04.15.08.03.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 08:03:43 -0700 (PDT) From: Caleb Connolly Date: Mon, 15 Apr 2024 16:03:40 +0100 Subject: [PATCH v2 3/3] serial: msm: calculate bit clock divider MIME-Version: 1.0 Message-Id: <20240415-b4-msm-serial-bitrate-v2-3-b7a048adc6a3@linaro.org> References: <20240415-b4-msm-serial-bitrate-v2-0-b7a048adc6a3@linaro.org> In-Reply-To: <20240415-b4-msm-serial-bitrate-v2-0-b7a048adc6a3@linaro.org> To: Lukasz Majewski , Sean Anderson , Caleb Connolly , Neil Armstrong , Sumit Garg , Tom Rini Cc: Robert Marko , u-boot-qcom@groups.io, u-boot@lists.denx.de X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=7339; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=XTpTsjLTJWrjvqRND9ja48RnvtIjexGDmK5UnoByeAo=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhjRZx9OdcXclPtepcK6YkfBjHU/D+tDQpe8/9Cnd1Ok5d f/c2XvxHaUsDIIcDLJiiiziJ5ZZNq29bK+xfcEFmDmsTCBDGLg4BWAibQsZ/il9qLGq0F3QqvAt UOu1xDrfzxM9jjK9OTWx0n6h0USVr3cYGZou/i6ITV//RPTUuTizcxw/cl893fU/efqx0C+6UvN 6txcBAA== 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 The driver currently requires the bit clock divider be hardcoded in devicetree (or use the hardcoded default from apq8016). The bit clock divider is used to derive the baud rate from the core clock: baudrate = clk_rate / csr_div clk_rate is the actual programmed core clock rate which is returned by clk_set_rate(), and this UART driver only supports a baudrate of 115200. We can therefore determine the appropriate value for UARTDM_CSR by iterating over the possible values and finding the one where the equation above holds true for a baudrate of 115200. Implement this logic and drop the non-standard DT bindings for this driver. Tested on dragonboard410c. Signed-off-by: Caleb Connolly Tested-by: Robert Marko --- Cc: Robert Marko --- doc/device-tree-bindings/serial/msm-serial.txt | 10 --- drivers/serial/serial_msm.c | 87 +++++++++++++++++++++----- 2 files changed, 70 insertions(+), 27 deletions(-) diff --git a/doc/device-tree-bindings/serial/msm-serial.txt b/doc/device-tree-bindings/serial/msm-serial.txt deleted file mode 100644 index dca995798a90..000000000000 --- a/doc/device-tree-bindings/serial/msm-serial.txt +++ /dev/null @@ -1,10 +0,0 @@ -Qualcomm UART (Data Mover mode) - -Required properties: -- compatible: must be "qcom,msm-uartdm-v1.4" -- reg: start address and size of the registers -- clock: interface clock (must accept baudrate as a frequency) - -Optional properties: -- bit-rate: Data Mover bit rate register value - (If not defined then 0xCC is used as default) diff --git a/drivers/serial/serial_msm.c b/drivers/serial/serial_msm.c index 8044d38518db..c05dda8bdb97 100644 --- a/drivers/serial/serial_msm.c +++ b/drivers/serial/serial_msm.c @@ -31,8 +31,18 @@ #define UARTDM_RXFS_BUF_SHIFT 0x7 /* Number of bytes in the packing buffer */ #define UARTDM_RXFS_BUF_MASK 0x7 #define UARTDM_MR1 0x00 #define UARTDM_MR2 0x04 +/* + * This is documented on page 1817 of the apq8016e technical reference manual. + * section 6.2.5.3.26 + * + * The upper nybble contains the bit clock divider for the RX pin, the lower + * nybble defines the TX pin. In almost all cases these should be the same value. + * + * The baud rate is the core clock frequency divided by the fixed divider value + * programmed into this register (defined in calc_csr_bitrate()). + */ #define UARTDM_CSR 0xA0 #define UARTDM_SR 0xA4 /* Status register */ #define UARTDM_SR_RX_READY (1 << 0) /* Word is the receiver FIFO */ @@ -52,9 +62,8 @@ #define UARTDM_TF 0x100 /* UART Transmit FIFO register */ #define UARTDM_RF 0x140 /* UART Receive FIFO register */ -#define UART_DM_CLK_RX_TX_BIT_RATE 0xCC #define MSM_BOOT_UART_DM_8_N_1_MODE 0x34 #define MSM_BOOT_UART_DM_CMD_RESET_RX 0x10 #define MSM_BOOT_UART_DM_CMD_RESET_TX 0x20 @@ -63,9 +72,9 @@ DECLARE_GLOBAL_DATA_PTR; struct msm_serial_data { phys_addr_t base; unsigned chars_cnt; /* number of buffered chars */ uint32_t chars_buf; /* buffered chars */ - uint32_t clk_bit_rate; /* data mover mode bit rate register value */ + uint32_t clk_rate; /* core clock rate */ }; static int msm_serial_fetch(struct udevice *dev) { @@ -155,34 +164,63 @@ static const struct dm_serial_ops msm_serial_ops = { .pending = msm_serial_pending, .getc = msm_serial_getc, }; -static int msm_uart_clk_init(struct udevice *dev) +static long msm_uart_clk_init(struct udevice *dev) { - uint clk_rate = fdtdec_get_uint(gd->fdt_blob, dev_of_offset(dev), - "clock-frequency", 115200); + struct msm_serial_data *priv = dev_get_priv(dev); struct clk clk; int ret; + long rate; ret = clk_get_by_name(dev, "core", &clk); if (ret < 0) { pr_warn("%s: Failed to get clock: %d\n", __func__, ret); - return ret; + return 0; } - ret = clk_set_rate(&clk, clk_rate); - if (ret < 0) - return ret; + rate = clk_set_rate(&clk, priv->clk_rate); - return 0; + return rate; +} + +static int calc_csr_bitrate(struct msm_serial_data *priv) +{ + /* This table is from the TRE. See the definition of UARTDM_CSR */ + unsigned int csr_div_table[] = {24576, 12288, 6144, 3072, 1536, 768, 512, 384, + 256, 192, 128, 96, 64, 48, 32, 16}; + int i = ARRAY_SIZE(csr_div_table) - 1; + /* Currently we only support one baudrate */ + int baud = 115200; + + for (; i >= 0; i--) { + int x = priv->clk_rate / csr_div_table[i]; + + if (x == baud) + /* Duplicate the configuration for RX + * as the lower nybble only configures TX + */ + return i + (i << 4); + } + + return -EINVAL; } static void uart_dm_init(struct msm_serial_data *priv) { /* Delay initialization for a bit to let pins stabilize if necessary */ mdelay(5); + int bitrate = calc_csr_bitrate(priv); + if (bitrate < 0) { + log_warning("Couldn't calculate bit clock divider! Using default\n"); + /* This happens to be the value used on MSM8916 for the hardcoded clockrate + * in clock-apq8016. It's at least a better guess than a value we *know* + * is wrong... + */ + bitrate = 0xCC; + } - writel(priv->clk_bit_rate, priv->base + UARTDM_CSR); + writel(bitrate, priv->base + UARTDM_CSR); writel(0x0, priv->base + UARTDM_MR1); writel(MSM_BOOT_UART_DM_8_N_1_MODE, priv->base + UARTDM_MR2); writel(MSM_BOOT_UART_DM_CMD_RESET_RX, priv->base + UARTDM_CR); writel(MSM_BOOT_UART_DM_CMD_RESET_TX, priv->base + UARTDM_CR); @@ -191,18 +229,27 @@ static void uart_dm_init(struct msm_serial_data *priv) writel(0x0, priv->base + UARTDM_DMEN); } static int msm_serial_probe(struct udevice *dev) { - int ret; struct msm_serial_data *priv = dev_get_priv(dev); + long rate; /* No need to reinitialize the UART after relocation */ if (gd->flags & GD_FLG_RELOC) return 0; - ret = msm_uart_clk_init(dev); - if (ret) - return ret; + rate = msm_uart_clk_init(dev); + if (rate < 0) + return rate; + if (!rate) { + log_err("Got core clock rate of 0... Please fix your clock driver\n"); + return -EINVAL; + } + + /* Update the clock rate to the actual programmed rate returned by the + * clock driver + */ + priv->clk_rate = rate; uart_dm_init(priv); return 0; @@ -210,15 +257,20 @@ static int msm_serial_probe(struct udevice *dev) static int msm_serial_of_to_plat(struct udevice *dev) { struct msm_serial_data *priv = dev_get_priv(dev); + int ret; priv->base = dev_read_addr(dev); if (priv->base == FDT_ADDR_T_NONE) return -EINVAL; - priv->clk_bit_rate = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), - "bit-rate", UART_DM_CLK_RX_TX_BIT_RATE); + ret = dev_read_u32(dev, "clock-frequency", &priv->clk_rate); + if (ret < 0) { + log_debug("No clock frequency specified, using default rate\n"); + /* Default for APQ8016 */ + priv->clk_rate = 7372800; + } return 0; } @@ -241,8 +293,9 @@ U_BOOT_DRIVER(serial_msm) = { #ifdef CONFIG_DEBUG_UART_MSM static struct msm_serial_data init_serial_data = { .base = CONFIG_VAL(DEBUG_UART_BASE), + .clk_rate = CONFIG_VAL(DEBUG_UART_CLOCK), }; #include