From patchwork Tue Jan 17 22:10:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rini X-Patchwork-Id: 1727773 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.a=rsa-sha256 header.s=google header.b=dx0iQeM9; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NxNQ00yN1z23gM for ; Wed, 18 Jan 2023 09:11:02 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2514185603; Tue, 17 Jan 2023 23:10:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="dx0iQeM9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4F5BE85602; Tue, 17 Jan 2023 23:10:55 +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=ham autolearn_force=no version=3.4.2 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) (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 E685885604 for ; Tue, 17 Jan 2023 23:10:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qv1-xf33.google.com with SMTP id m12so20517305qvt.9 for ; Tue, 17 Jan 2023 14:10:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; 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=7ZyVJWy2QYLGhRCU26w+bGh7UnYZZOJaO3R2D2JT5vw=; b=dx0iQeM9OZShiKEIMKYXISNeJZroPjrp3D6cfo/Sm7sOP+jd3V6IK98IyU4eCI5bSv inlWiMLwSfEmb+GDtRXP08qDJ8doiZhIFCjisxO0tl7f75hhi5bzt2EnEDrJmLY+b83I 6POOgfSUs/F7H3S2gw5HBdzcQ9+rmd6ATKkqw= 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=7ZyVJWy2QYLGhRCU26w+bGh7UnYZZOJaO3R2D2JT5vw=; b=Dx7eBnNF2yICnJwtiSDgvcofOZZKtQ1MEbiB1J0ni3PmMi2wSz+Zoox8fHXK0AoaDY UD2F3rnO/rOrjy1cqHjyjQZ27bKJt7AIf8gjduOQu0R+zJrlIpqTxCzefzCUKPHeSXvi n9H9tVlvsenTxuiKASrNpSfL76xH7rOAJYL03U2pWkVFaMZMMiai4/6wNhGu+PzLlC20 vpdPLtWJyqSfZktI6c2ysg+qEX2QIOkbfN1CuAFEj3z8U9w+kF6RgqZ/EBFlf0Nm+Yv0 fRKecAil8tPkPrx4fw7Ef9hl9vaSmGwMlfY0rdSEtp8YnbPZqY7XJn8Y+ujAy2UBP5PH 0I8Q== X-Gm-Message-State: AFqh2kozuGMQIHEEshfZ/KWkaTd2HK/A3grIuu1Aws8GoHWTT+bFa60l XEt7hwJEYU59csZ5PH6LjT/h6c5y3FDM4ygBvSg= X-Google-Smtp-Source: AMrXdXs6RLnq+att68L/1WkM6ifo3roe+UuJks3SOC+573WD60SW6dSDEvvXdYp6vLckjbidrJ+dqg== X-Received: by 2002:a05:6214:3d9c:b0:535:1b57:ba78 with SMTP id om28-20020a0562143d9c00b005351b57ba78mr8281119qvb.11.1673993451647; Tue, 17 Jan 2023 14:10:51 -0800 (PST) Received: from bill-the-cat.lan (2603-6081-7b00-6400-3487-94a5-6d7e-19f3.res6.spectrum.com. [2603:6081:7b00:6400:3487:94a5:6d7e:19f3]) by smtp.gmail.com with ESMTPSA id f8-20020a05620a408800b006b5cc25535fsm21569446qko.99.2023.01.17.14.10.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 14:10:51 -0800 (PST) From: Tom Rini To: u-boot@lists.denx.de Cc: Simon Glass , Sergei Antonov , Quentin Schulz , Andre Przywara Subject: [PATCHv2 05/19] dm: ns16550: Restore how we define UART_REG Date: Tue, 17 Jan 2023 17:10:50 -0500 Message-Id: <20230117221050.630746-1-trini@konsulko.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230110161946.3816866-5-trini@konsulko.com> References: <20230110161946.3816866-5-trini@konsulko.com> 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 Prior to commit 9591b63531fa ("Convert CONFIG_SYS_NS16550_MEM32 et al to Kconfig") we had defined CONFIG_SYS_NS16550_REG_SIZE to -1 with DM_SERIAL such that we would then have a size 0 character array. This resulted in functionally no padding. The confusion on my part came from dealing with the constraints around platforms that do not use DM_SERIAL in SPL/TPL. After Andre Przywara reported that sunxi was broken, I've re-read the code and comments again and thought on this harder. What we want I believe is what this patch does now. If DM_SERIAL is defined for this stage, regardless of CONFIG_SYS_NS16550_REG_SIZE then we will dynamically handle reg shifts and 'struct ns16550' needs no padding (which is functionally what unsigned char foo[0] provides). This is the same case as NS16550_DYNAMIC and DEBUG_UART. Expand the existing comment here slightly. Otherwise, we will have CONFIG_SYS_NS16550_REG_SIZE set to a non-zero value, and handle padding within the struct. Cc: Simon Glass Cc: Sergei Antonov Cc: Quentin Schulz Cc: Andre Przywara Fixes: 9591b63531fa ("Convert CONFIG_SYS_NS16550_MEM32 et al to Kconfig") Signed-off-by: Tom Rini Reviewed-by: Andre Przywara Tested-by: Andre Przywara Tested-by: Quentin Schulz --- include/ns16550.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/include/ns16550.h b/include/ns16550.h index 243226fc3d94..e7e68663d030 100644 --- a/include/ns16550.h +++ b/include/ns16550.h @@ -26,15 +26,13 @@ #include -#if CONFIG_IS_ENABLED(DM_SERIAL) && !defined(CONFIG_SYS_NS16550_REG_SIZE) +#if CONFIG_IS_ENABLED(DM_SERIAL) || defined(CONFIG_NS16550_DYNAMIC) || \ + defined(CONFIG_DEBUG_UART) /* * For driver model we always use one byte per register, and sort out the - * differences in the driver + * differences in the driver. In the case of CONFIG_NS16550_DYNAMIC we do + * similar, and CONFIG_DEBUG_UART is responsible for shifts in its own manner. */ -#define CONFIG_SYS_NS16550_REG_SIZE (-1) -#endif - -#if defined(CONFIG_NS16550_DYNAMIC) || defined(CONFIG_DEBUG_UART) #define UART_REG(x) unsigned char x #else #if !defined(CONFIG_SYS_NS16550_REG_SIZE) || (CONFIG_SYS_NS16550_REG_SIZE == 0)