Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B387AC77B70 for ; Mon, 17 Apr 2023 07:14:07 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8D4E985830; Mon, 17 Apr 2023 09:14:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.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=amd.com header.i=@amd.com header.b="zxV15hd4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F400C8215F; Mon, 17 Apr 2023 09:14:03 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20608.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eab::608]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8505685B57 for ; Mon, 17 Apr 2023 09:14:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=michal.simek@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AXnwcEI0jtmDxjYAQ9809qBlw2Mzf1lsjZBHZ3vPcD+XiCTtJ2mqZHz4stQ9SsT4GRXNpr5V8OZlR3FZzs7SL9+S75eHMcqno5yuRQfD34B68g+qAz+MZLHSl3Nfw+uCIaZ/AWzRShSTwVWgt2KMjOtev4PGPdtFxxs+GnLPLhIgv+w4fuX+P6TH5DTnaK+0wtN+Uuddg/SOV3wIJWeH42Eago4Ndyoyx+X08a02kHISk5Lyo9s8kJ2CA3YLWphG76vsIjH1WixozwJV05j2VE9+qbXJaPZZHdeDUWHYZiJhnINgHbMDNVq017p7tUl6VTPKkUpk4gR4CvI9VTZFTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=82q3R2JkLgKAWxXKKEIxPYaaNoBusNLP3d4iKYimMT4=; b=ezjiHutaiGda/vSkIAf6I0vgzEuXdoG6e4pQ3782B2ZmFegZfaueoMW+wvP5t1ku23aBSCJhxcC1AHfv67joBrqD7m8Bz2Fj2wzbIToXHaNA6HPiurR/SmwKI488sxBOZrawaAY2A9PrwWW5WiH4WllyXQnlzkxgFW0To0DpnujTNms7ykQD/KV/oSrVtl1jH8G52qI1rE8OqDmvzccS789lJ7fiogV3bFnQK1NJFvpQezbe0WCuPkiFb4kMth9kG5a0uZpwIaBJdx/7vNsGBGUxq0soycj3L6cvXb2JFMPMUJXPzmcH5PjvCuniz8qynaJOUoreXCLMOVHypC4QHg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=82q3R2JkLgKAWxXKKEIxPYaaNoBusNLP3d4iKYimMT4=; b=zxV15hd4wlK+oemjc72D5HA6AQ4WglJLzpttO+VscUjkdQcdmTmzvHY61votpn5/u6V0L9QFkwV8JNigJ6K7M1TWSnxCNZh/cXOxfO/udee+yq/Zjxlurr91dGA+ZSF5/BMNgx+uBiEIr5/1W1cjb9SgHkLlRzxnxMXYoE61Ul8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BYAPR12MB4758.namprd12.prod.outlook.com (2603:10b6:a03:a5::28) by SJ0PR12MB6854.namprd12.prod.outlook.com (2603:10b6:a03:47c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.47; Mon, 17 Apr 2023 07:13:56 +0000 Received: from BYAPR12MB4758.namprd12.prod.outlook.com ([fe80::8c5f:e48:a658:7611]) by BYAPR12MB4758.namprd12.prod.outlook.com ([fe80::8c5f:e48:a658:7611%2]) with mapi id 15.20.6298.045; Mon, 17 Apr 2023 07:13:56 +0000 Message-ID: <151f739f-bdc8-c9b5-a3ee-e25b633c5916@amd.com> Date: Mon, 17 Apr 2023 09:13:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v2 1/2] serial: zynqmp: Fetch baudrate from dtb and update Content-Language: en-US To: Venkatesh Yadav Abbarapu , u-boot@lists.denx.de Cc: sjg@chromium.org, git@xilinx.com, Algapally Santosh Sagar References: <20230417042833.3592-1-venkatesh.abbarapu@amd.com> <20230417042833.3592-2-venkatesh.abbarapu@amd.com> From: Michal Simek In-Reply-To: <20230417042833.3592-2-venkatesh.abbarapu@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: VI1PR07CA0218.eurprd07.prod.outlook.com (2603:10a6:802:58::21) To BYAPR12MB4758.namprd12.prod.outlook.com (2603:10b6:a03:a5::28) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR12MB4758:EE_|SJ0PR12MB6854:EE_ X-MS-Office365-Filtering-Correlation-Id: 219119d4-a26f-474c-2361-08db3f134e9e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OdDkewXTzGJC4kVSU/vD0VQJIP1BzDpw3lXM5lhoUoJOfFXnDP6vNirHZJJ1Q7nWCeIwb2ZcRiPhe+Ev3kHCOKw5UFhrEvkGhFGHuWnSMAh2gKQLCEmrHMIJBJgeYUQBe/P5mN9A3q9uc9bpmhmlJ1Ut+tm7B3eIlmfQQNKfUU0d+L3L2zRDutiK023ugPK/kioQreMsYqyANBk/fQqrGtK2xdlazDj4ESROmY4LnDOLa01MgEVmrLJbZrFzSc/S/IVXAy4RbixlPKmxZWEhIDHmaKklbdlKyyr0PbJ9D68OrYpUpAWD4ZoVAUR0hGwFpe5i+DD9+I0/iREYdZoqCwaPtdkP/A443wGvttZ845HDWvipocivgJn3gDgpSj9zbvf7y5JyzDhCuOv8E1/DkviDSAUcF+KzHLiUp0Ao8DgXkoAlyNhRgkO7DlznmO30Ieq73qdn6bp9vombZhzrvb10HiHXfEF4ID/p0Ovel9heX2tjo4zHooA4Hl6rQoB89YyxJ1XwQBE10x506tHkLp7jcp5yg5XZPXAr88L/LjpDxU5O24KyVPEpDfUGY0bumqB5NLjMfBArQy88Cjue4jKQW2lJWsgQWP5LpQyNmzYzTrFCp8q6KisGX7VeiHzrKkx5vyfmueAFfv8EPWp00g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR12MB4758.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(376002)(39860400002)(366004)(136003)(396003)(346002)(451199021)(86362001)(31696002)(36756003)(478600001)(8676002)(6666004)(6486002)(316002)(8936002)(4326008)(66946007)(38100700002)(66556008)(41300700001)(66476007)(2616005)(83380400001)(53546011)(186003)(6506007)(26005)(6512007)(31686004)(15650500001)(2906002)(5660300002)(44832011)(43740500002)(45980500001); DIR:O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lDVnQ5N3Z2?= =?utf-8?B?SUJwZ3M3TERoYkMrL1hSSzZLOEp5b2Z5YlVhVWcySksralBzTW9zSEpDY2E1?= =?utf-8?B?cHo3TFhFcXYzQkNRdytMS3EvVUVOQmZpNm41ME1OOVhmMXZSem5qOXpmZDYr?= =?utf-8?B?bGV3cGJKOG94dUg2Q0xVZWh3dWIrak5aUU9oOWEyN1laTUhDVE9ldmJUeEpa?= =?utf-8?B?dlZiS0RnZVBvbEw0eU5tZzRWZDFLZnU2SncrT3pGRHN4OHJkZTFEZEdmeFgx?= =?utf-8?B?WFB4ZnBoeHRCSzEyc3psK0N1MlNVbk1oWVV4SWJseUFUNEZTMS9oajh0cmpY?= =?utf-8?B?eHFKRUZCa0wvZG9pMGYvS3JpelZBc2grMWNEbEc3SldHeXNlZmxiMEpnYzZC?= =?utf-8?Q?MocIzM9r7XW2g+dJBwOwA8I14?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 219119d4-a26f-474c-2361-08db3f134e9e X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB4758.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2023 07:13:56.2145 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: m6dIHp8naJqBEAP/Hc9s2C+5kAyz9MiXkitPUvE1jnurqz8b+0Y4fIEWnGb0nbIg X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6854 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 On 4/17/23 06:28, Venkatesh Yadav Abbarapu wrote: > From: Algapally Santosh Sagar > > The baudrate configured in .config is taken by default by serial. If > change of baudrate is required then the .config needs to changed and > u-boot recompilation is required or the u-boot environment needs to be > updated. > > To avoid this, support is added to fetch the baudrate directly from the > device tree file and update. > The serial, prints the log with the configured baudrate in the dtb. > The commit c4df0f6f315c ("arm: mvebu: Espressobin: Set default value for > $fdtfile env variable") is taken as reference for changing the default > environment variable. > > The default environment stores the default baudrate value, When default > baudrate and dtb baudrate are not same glitches are seen on the serial. > So, the environment also needs to be updated with the dtb baudrate to > avoid the glitches on the serial. > > Signed-off-by: Algapally Santosh Sagar > Signed-off-by: Venkatesh Yadav Abbarapu > --- > drivers/serial/Kconfig | 16 ++++++++++++ > drivers/serial/serial-uclass.c | 32 +++++++++++++++++++++++ > include/configs/mvebu_armada-37xx.h | 1 - > include/configs/xilinx_zynqmp.h | 3 ++- > include/env_default.h | 7 ++++- > include/env_internal.h | 2 +- > include/fdtdec.h | 8 ++++++ > include/serial.h | 1 + > lib/fdtdec.c | 40 +++++++++++++++++++++++++++++ > 9 files changed, 106 insertions(+), 4 deletions(-) > > diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig > index 10d07daf27..96cea87f45 100644 > --- a/drivers/serial/Kconfig > +++ b/drivers/serial/Kconfig > @@ -24,6 +24,22 @@ config BAUDRATE > in the SPL stage (most drivers) or for choosing a default baudrate > in the absence of an environment setting (serial_mxc.c). > > +config SERIAL_DT_BAUD > + bool "Fetch serial baudrate from device tree" > + depends on DM_SERIAL && SPL_ENV_SUPPORT > + select DEFAULT_ENV_IS_RW > + help > + Select this to enable fetching and setting of the baudrate > + configured in the DT. Replace the default baudrate with the DT > + baudrate and also set it to the environment. > + > +config DEFAULT_ENV_IS_RW > + bool "Make default environment as writable" > + depends on DM_SERIAL > + help > + Select this to enable to make default environment writable. This > + allows modifying the default environment. This is one separate patch which is simply move to Kconfig and convert armada. > + > config REQUIRE_SERIAL_CONSOLE > bool "Require a serial port for console" > # Running without a serial console is not supported by the > diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c > index 067fae2614..d77d3bda36 100644 > --- a/drivers/serial/serial-uclass.c > +++ b/drivers/serial/serial-uclass.c > @@ -154,12 +154,44 @@ static void serial_find_console_or_panic(void) > } > #endif /* CONFIG_SERIAL_PRESENT */ > > +#ifdef CONFIG_SERIAL_DT_BAUD > +int serial_get_valid_baudrate(int baud) > +{ > + int i; > + > + for (i = 0; i < ARRAY_SIZE(baudrate_table); ++i) { > + if (baud == baudrate_table[i]) > + return 0; > + } > + > + return -EINVAL; > +} > +#endif > + > /* Called prior to relocation */ > int serial_init(void) > { > #if CONFIG_IS_ENABLED(SERIAL_PRESENT) > serial_find_console_or_panic(); > gd->flags |= GD_FLG_SERIAL_READY; > +#ifdef CONFIG_SERIAL_DT_BAUD > + int ret = 0; > + char *ptr = &default_environment[0]; > + > + /* > + * Fetch the baudrate from the dtb and update the value in the > + * default environment. > + */ > + ret = fdtdec_get_baud_from_dtb(gd->fdt_blob); > + if (ret != -EINVAL && ret != -EFAULT) { > + gd->baudrate = ret; > + > + while (*ptr != '\0' && *(ptr + 1) != '\0') > + ptr++; > + ptr += 2; > + sprintf(ptr, "baudrate=%d", gd->baudrate); > + } > +#endif > serial_setbrg(); > #endif > > diff --git a/include/configs/mvebu_armada-37xx.h b/include/configs/mvebu_armada-37xx.h > index 76e148f55e..18b55be0d8 100644 > --- a/include/configs/mvebu_armada-37xx.h > +++ b/include/configs/mvebu_armada-37xx.h > @@ -30,7 +30,6 @@ > /* > * Environment > */ > -#define DEFAULT_ENV_IS_RW /* required for configuring default fdtfile= */ > > #ifdef CONFIG_MMC > #define BOOT_TARGET_DEVICES_MMC(func, i) func(MMC, mmc, i) > diff --git a/include/configs/xilinx_zynqmp.h b/include/configs/xilinx_zynqmp.h > index 011f0034c5..8620bda489 100644 > --- a/include/configs/xilinx_zynqmp.h > +++ b/include/configs/xilinx_zynqmp.h > @@ -176,7 +176,8 @@ > #ifndef CFG_EXTRA_ENV_SETTINGS > #define CFG_EXTRA_ENV_SETTINGS \ > ENV_MEM_LAYOUT_SETTINGS \ > - BOOTENV > + BOOTENV \ > + ENV_RW_FILLER This is not what TOM was saying. You shouldn't have a need to update every board which wants this feature. Just enable it and get it. It means this should be the part of env_default.h directly. > #endif > > /* SPL can't handle all huge variables - define just DFU */ > diff --git a/include/env_default.h b/include/env_default.h > index c0df39d62f..8ff0422ccf 100644 > --- a/include/env_default.h > +++ b/include/env_default.h > @@ -23,7 +23,7 @@ env_t embedded_environment __UBOOT_ENV_SECTION__(environment) = { > { > #elif defined(DEFAULT_ENV_INSTANCE_STATIC) > static char default_environment[] = { > -#elif defined(DEFAULT_ENV_IS_RW) > +#elif defined(CONFIG_DEFAULT_ENV_IS_RW) > char default_environment[] = { > #else > const char default_environment[] = { > @@ -47,6 +47,11 @@ const char default_environment[] = { > #if defined(CONFIG_BAUDRATE) && (CONFIG_BAUDRATE >= 0) > "baudrate=" __stringify(CONFIG_BAUDRATE) "\0" > #endif > +#ifdef CONFIG_SERIAL_DT_BAUD > +#define ENV_RW_FILLER "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" > +#else > +#define ENV_RW_FILLER > +#endif Can you do just this here? #ifdef CONFIG_SERIAL_DT_BAUD "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" #endif Or if this is something what needs to be at the end just move it there. Thanks, Michal