From patchwork Wed Apr 12 14:30:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 672642 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:184:0:0:0:0 with SMTP id p4csp370333wrx; Wed, 12 Apr 2023 07:31:43 -0700 (PDT) X-Google-Smtp-Source: AKy350ZNZyDgTpM9X5I3hoxjjZFNy40S7ubbz9DAwRAcJ8E9uteaUfijvirm3AFGconePYGDnZsB X-Received: by 2002:ac8:7f01:0:b0:3d5:3a1b:61c8 with SMTP id f1-20020ac87f01000000b003d53a1b61c8mr18888316qtk.44.1681309903013; Wed, 12 Apr 2023 07:31:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681309903; cv=none; d=google.com; s=arc-20160816; b=pN9tEKYwmTMB4ol9ju6iQAr9bWjoI0cC0h9g29ABSOoEGwldE6sLto/7cE87tsl+Kq wdjB+0gwU6PCXqvthnQDu4gDxUVhck947arQurBBx84BUNulO7lzNmGxva06tICdbQze gYsqGOwf3dKbN8mDAzUaXPS4W4IPOzqFU+/34CMPor6ioZii4mORjubbb0N8zBUYfns2 RRbdVVl+DDUFycQAZ0kN+9ZqxY2dk6FtBB/Ua9U+5zslTABj+zXmLaDjgGkMPU83wAme 6C0yIwJSRUg8xB69m9rCiCL6TWFv2RsTcMDRMxvr0bFTGYjX6r34Skdl0BGaSKt2y6+j vJbA== 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=q+IN99fyNd9MTSH6CRsJmtiRUV3HScQXLXTSdG52Y3Q=; b=HtNRHw68BTVJh61WE9SM0jQj/Gt72TEzHR+p+OZQ95e+OQhgFmAbnZApDXkpicc+8D 0TfnAw3IiZ5RdnzN4y2YtnqMFp0hTQzBdvUdyBXnHxdj6vFANYp3JLjcqgrqjnltG7wK ZsPxK3EEYQU6JRamYILjGoGs31UFn2B8Pz0YSI8x+13apCI6IopBOIyXqyfeqnsfbZwD q+m2gJfp16pIFuF95wiBe1YjatfQMO+FO+zDfPvhXkXThBByCDNwNC8H3dZ4/Ao1Ifpi yxcaPIHnC4OHY/cdlYMap3Va2xxXk4opBCL4/hl6e75HWgVgrPcNvGRBi/A5+1Y3fwns b0lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aNDqeV0K; 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 f20-20020a05622a1a1400b003e4e4300960si10882945qtb.331.2023.04.12.07.31.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Apr 2023 07:31:42 -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=aNDqeV0K; 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 9274885F9D; Wed, 12 Apr 2023 16:30:48 +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="aNDqeV0K"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E712985F9D; Wed, 12 Apr 2023 16:30:22 +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-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) (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 010E685F88 for ; Wed, 12 Apr 2023 16:30:19 +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=vladimir.zapolskiy@linaro.org Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-4ec816ccb80so196443e87.1 for ; Wed, 12 Apr 2023 07:30:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681309819; x=1683901819; 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=q+IN99fyNd9MTSH6CRsJmtiRUV3HScQXLXTSdG52Y3Q=; b=aNDqeV0Kh7zGqm+iXDxV3Y9Qv9HgNPEuKNB327X+k6WoDlbqfID0FuV+F6pFxzb+vP QtcfkVEXQ4IFgRL0gZOXJHmjsU2zHLtVt7oL+jBKBnQEv1hObIC7U/3fOf339JVCqJUg N5uwX9alc8lJEJbUtwqSkQ7A42RQNhwIUp07djQ8afpI/rME6J4Wg5JUsMplFrFO5Te5 bfjcux/17uziTf5seCPYp2AgtqjuxiwM8ZS8OMVszySu2pbMB5iYAQ4delmztgL1QTMw zeIsrYaj/pBnQeiUm6/7cmSf0INerlBouC8EM/hCrHnI4xwFRamRvC9cahPbAisVyJsr miFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681309819; x=1683901819; 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=q+IN99fyNd9MTSH6CRsJmtiRUV3HScQXLXTSdG52Y3Q=; b=KKkDc+VVnSQ2zhqg3AU23q4RBiKzHPdNAv93/GARASu8o5ddUW32ot/k85FM3wA+bx kj2A6Y6z14KecU/bjXgGSackbAvG1uKlck2kV5mffXvorXM/GAiwfhDVvd+dMB+bLSnx tLlDXJKBwADDs0ulg9t6jB6m3EwL0BNfgpnVy/uzTOEVgRmQpFoYXxYwXPBxuLi6btHa Xzatgk2LSHiIfgHGKayxe+U4xu3PK/HfBgW0z6/a7RLs84Ei0mkj9I/ye0XdbUuokw56 yazQwrnMVRO3Qu1isdbENyozgvTPx+fGd5bqV+mURxl2a4gkplUB3jGKLfVQLeQuu0bA FiUA== X-Gm-Message-State: AAQBX9cDizQtheV0/af9fSMNURgHB3a7KyoZ8VXhiBkzQir9/Fznb886 f4RtN81nL1RugXp+rMv+qzOm8w== X-Received: by 2002:a05:651c:1607:b0:2a7:970a:1c1b with SMTP id f7-20020a05651c160700b002a7970a1c1bmr719754ljq.3.1681309819689; Wed, 12 Apr 2023 07:30:19 -0700 (PDT) Received: from localhost.localdomain (88-112-131-206.elisa-laajakaista.fi. [88.112.131.206]) by smtp.gmail.com with ESMTPSA id z2-20020a2e8e82000000b002a7729eea3dsm1861054ljk.88.2023.04.12.07.30.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Apr 2023 07:30:18 -0700 (PDT) From: Vladimir Zapolskiy To: Tom Rini , Simon Glass Cc: Ramon Fried , Konrad Dybcio , Bhupesh Sharma , u-boot@lists.denx.de Subject: [PATCH v2 8/9] serial: msm-geni: correct oversampling value based on QUP hardware revision Date: Wed, 12 Apr 2023 17:30:05 +0300 Message-Id: <20230412143006.80946-9-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230412143006.80946-1-vladimir.zapolskiy@linaro.org> References: <20230412143006.80946-1-vladimir.zapolskiy@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.8 at phobos.denx.de X-Virus-Status: Clean Starting from QUP v2.5 the value of oversampling is changed from 32 to 16, keeping the old value on newer platforms results on wrong set UART IP clock divider, thus the asked baudrate does not correspond to the actually set with all the consequencies for a user. The change links the driver to a new Qualcomm GENI SE QUP driver to get its hardware version and update the oversampling value. Deliberately the code under CONFIG_DEBUG_UART_MSM_GENI is not touched, since a wanted baudrate can be controlled by setting a modified CONFIG_DEBUG_UART_CLOCK build time variable. Signed-off-by: Vladimir Zapolskiy --- drivers/serial/Kconfig | 2 ++ drivers/serial/serial_msm_geni.c | 32 +++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 10d07daf2777..7faf67844424 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -946,6 +946,8 @@ config MSM_SERIAL config MSM_GENI_SERIAL bool "Qualcomm on-chip GENI UART" + select MISC + imply QCOM_GENI_SE help Support UART based on Generic Interface (GENI) Serial Engine (SE), used on Qualcomm Snapdragon SoCs. Should support all qualcomm SOCs diff --git a/drivers/serial/serial_msm_geni.c b/drivers/serial/serial_msm_geni.c index 29fae810d6fe..b76ed3a30017 100644 --- a/drivers/serial/serial_msm_geni.c +++ b/drivers/serial/serial_msm_geni.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #define UART_OVERSAMPLING 32 @@ -110,6 +111,10 @@ #define TX_FIFO_DEPTH_MSK (GENMASK(21, 16)) #define TX_FIFO_DEPTH_SHFT 16 +/* GENI SE QUP Registers */ +#define QUP_HW_VER_REG 0x4 +#define QUP_SE_VERSION_2_5 0x20050000 + /* * Predefined packing configuration of the serial engine (CFG0, CFG1 regs) * for uart mode. @@ -127,6 +132,7 @@ DECLARE_GLOBAL_DATA_PTR; struct msm_serial_data { phys_addr_t base; u32 baud; + u32 oversampling; }; unsigned long root_freq[] = {7372800, 14745600, 19200000, 29491200, @@ -246,7 +252,7 @@ static int msm_serial_setbrg(struct udevice *dev, int baud) priv->baud = baud; - clk_rate = get_clk_div_rate(baud, UART_OVERSAMPLING, &clk_div); + clk_rate = get_clk_div_rate(baud, priv->oversampling, &clk_div); geni_serial_set_clock_rate(dev, clk_rate); geni_serial_baud(priv->base, clk_div, baud); @@ -480,6 +486,28 @@ static const struct dm_serial_ops msm_serial_ops = { .setbrg = msm_serial_setbrg, }; +static void geni_set_oversampling(struct udevice *dev) +{ + struct msm_serial_data *priv = dev_get_priv(dev); + struct udevice *parent_dev = dev_get_parent(dev); + u32 geni_se_version; + int ret; + + priv->oversampling = UART_OVERSAMPLING; + + /* + * It could happen that GENI SE IP is missing in the board's device + * tree or GENI UART node is a direct child of SoC device tree node. + */ + if (device_get_uclass_id(parent_dev) != UCLASS_MISC) + return; + + ret = misc_read(parent_dev, QUP_HW_VER_REG, + &geni_se_version, sizeof(geni_se_version)); + if (!ret && geni_se_version >= QUP_SE_VERSION_2_5) + priv->oversampling /= 2; +} + static inline void geni_serial_init(struct udevice *dev) { struct msm_serial_data *priv = dev_get_priv(dev); @@ -523,6 +551,8 @@ static int msm_serial_probe(struct udevice *dev) { struct msm_serial_data *priv = dev_get_priv(dev); + geni_set_oversampling(dev); + /* No need to reinitialize the UART after relocation */ if (gd->flags & GD_FLG_RELOC) return 0;