From patchwork Fri Apr 21 17:50:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 675871 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp989543wrs; Fri, 21 Apr 2023 10:52:44 -0700 (PDT) X-Google-Smtp-Source: AKy350aCbuXsh+hC8mjXqwKljezyG7JdCulDe0v31pzojoI5HeXA9FPb2D6FIuow6V5XqPM2r4HP X-Received: by 2002:a05:6a00:182a:b0:63d:2648:f93e with SMTP id y42-20020a056a00182a00b0063d2648f93emr7664337pfa.20.1682099564391; Fri, 21 Apr 2023 10:52:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682099564; cv=none; d=google.com; s=arc-20160816; b=EnBQL95h4zwkJdG3nTsSs9u/XRLVoXYYGK4J7PzNBs2FZeJeZ0jli0BECmY+wW+dwa EH4NvAmv7RFT6X2JGFaLx4QlREzl4y/k/fwN3APzYF4OPxrwZDtWFv9PmWzSWKiPt6NL JWKTgg86PBOliqEufZzJuVvfI5atIse+wdUueTx5x+WP9HLUfy0dGuSFpgGKH7PIslJE y6kXzjiwV0ptnehBgnoHsLmj5Vr6+vBo0+3g+P/cXj7XC919G7WhARY8rW6Qw//EsAGT +dXSSGQVfBbZKYV9QACvc+4X1vAoNKgb33dzjE1NYhPYzZxjCue+iS5yRz4ZK+o30KCe y46g== 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=c0OdR0wxOR1/QZ9nd1Yf9IBSGbGWHouODsr4StWTM8o=; b=j5AgEF2ETH8GNYbLOZoTIdGQQoIbt6boSIGt5RHkPgw2Wsm9EjeESEGQazELyGMVEx XbY3cjM2srQgsPXleKarkZpZO0VjsBgVy67cDkNdZT+XioM8vLFPVP/p0FtlNCPwg+3S L52+iydmMJKtTEOYgt8hNkLIdftphxWZamKgiCN0btsXX8MbwMJqSt/PZP6hwT0ddZwW lG7dgC02UWOkNpGzQHhXBu1yoPZB3l67TDFy0Yp8yFXiMHlGbAn9WJsQdHOFJE5HdvNI tcQXEdwMlXRLmK2pjE6olPBijPSm+0FPevXb2JA2T9PeVjVEqJIr1HB3Z6CGg5dRj0Et 9hqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p+uhXXen; 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 bk13-20020a056a02028d00b0051b54dccff6si4286648pgb.727.2023.04.21.10.52.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 10:52:44 -0700 (PDT) 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=p+uhXXen; 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 B734D863D7; Fri, 21 Apr 2023 19:51:12 +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="p+uhXXen"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0DD87863B3; Fri, 21 Apr 2023 19:50:58 +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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) (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 0800486358 for ; Fri, 21 Apr 2023 19:50:54 +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-lj1-x231.google.com with SMTP id 38308e7fff4ca-2a8dc09e884so3255751fa.1 for ; Fri, 21 Apr 2023 10:50:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1682099454; x=1684691454; 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=c0OdR0wxOR1/QZ9nd1Yf9IBSGbGWHouODsr4StWTM8o=; b=p+uhXXen7c1fZhcYABpk/xtBZhoe9dd3b7T1ebnSnj/Znq1SCqTnpbnXe7OQmvsTxO 2mXGoZXWs4ZmkSNhtauKSzCyUx7o5gvMwwoBrodd8GaohdhXiDgcc5+fujGTChxOLBAL UCpl7P1W9o4gxQfI7w1L1/KvNS1PgMa+/ybUrv0Hea7qIQ90J62pQkHerJomIQzpuIoF IgKf4cdqcJwIQQob/UPt+pQbX32cmf3SHrol1fu0Pzc8TktiJc9KCjoB0D3hQ1NabhOb njRTcKlXR1KluVH+H9LQ5GwQoFIzd/Id528ee8G1SskK0U8nShz0bvrL6FQqoLCChdwu SkjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682099454; x=1684691454; 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=c0OdR0wxOR1/QZ9nd1Yf9IBSGbGWHouODsr4StWTM8o=; b=F4SaXYzAcjitOrRQFrPfbcMas8sDpCKbXAtIKhb8XrFzJrvo7B1p0GH8hLClYpr7p8 XS8C6ny7ul1Fs8p8RQ30ZKj3TZ+an+rcDqhevPFcu/6pwKeWfX2RWCGhQ9pp2J5q/7ZK 53fv4GOKqj89nZ/XFhGdG/J+Rvnmw9MOrOu9vWd63QCHLYGmloAyraCB9XdLmuVqXw88 plat3RA0P1xjiBd73k6NNx7cv2/QWr51G2DSRyyssQBy3EU/GgLKUD/zRKQNmEc2eXAK Z4I6VuHtOKrHy+eRG+sSZKHxvJHdxG9SNFcvpjUw7mo7fLrjYGfZrHkVAtn8SYQeLSzN ZYWw== X-Gm-Message-State: AAQBX9e3iF0JtQaoxp4fckHeeQm1QdQzvpQ0uU+Zn6n3wkSNy8AhSHog ZDNb1dfbkFUnksaZlpslGgQHig== X-Received: by 2002:a2e:2a01:0:b0:2a9:f4e9:1a3d with SMTP id q1-20020a2e2a01000000b002a9f4e91a3dmr1466539ljq.2.1682099454058; Fri, 21 Apr 2023 10:50:54 -0700 (PDT) Received: from localhost.localdomain (88-112-131-206.elisa-laajakaista.fi. [88.112.131.206]) by smtp.gmail.com with ESMTPSA id u24-20020a2e8558000000b002a7aa25c3b6sm674256ljj.88.2023.04.21.10.50.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Apr 2023 10:50:53 -0700 (PDT) From: Vladimir Zapolskiy To: Tom Rini , Simon Glass , Ramon Fried , Dzmitry Sankouski Cc: Konrad Dybcio , Bhupesh Sharma , u-boot@lists.denx.de Subject: [PATCH v3 8/9] serial: msm-geni: correct oversampling value based on QUP hardware revision Date: Fri, 21 Apr 2023 20:50:40 +0300 Message-Id: <20230421175041.275566-9-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230421175041.275566-1-vladimir.zapolskiy@linaro.org> References: <20230421175041.275566-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 | 35 +++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index bb5083201b38..d50a1fd3f382 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -938,6 +938,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..78fd9389c036 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,31 @@ 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 != sizeof(geni_se_version)) + return; + + if (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 +554,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;