From nobody Mon Sep 16 19:20:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=ti.com ARC-Seal: i=1; a=rsa-sha256; t=1721389404; cv=none; d=zohomail.com; s=zohoarc; b=giC+9IOh1d3k7cMV1MA1ccMEtfr/a0I+XqLKbSuud4DNBftn4OTGsDoIFXy+5Fr/uArXVNoDTWMNSetO2zAR0a+bc2rp1jFHTs89OJ5HlFfcF76ZTm1yGoB9bxFgFHS3Jy3VOMI1P42KZCaox2J0TS/LcXyAkDV/LASMqpDG4sM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721389404; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=L0bRkCPaGDdgFautpIKHYtZ+R9TkSjccH9W/hhznknM=; b=eqlo4NtQ3/YC7ZncNxjdjHyBtb+i6IZjx/IVqSBV+35Na5ecXLhTexVl80t6hTw1mg2HEjwIRHBpR23UFC3SgEyExMa+4/02LRbA4TBTvQ/3wIeMNOZZZ5cbKwF5D6VYlM0qbQKltmjHuBD0a4gMd/nHhIPHaD08Qegm9Gc7puc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1721389404274260.5533171202118; Fri, 19 Jul 2024 04:43:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.761021.1170993 (Exim 4.92) (envelope-from ) id 1sUm0r-0005o4-Jk; Fri, 19 Jul 2024 11:43:01 +0000 Received: by outflank-mailman (output) from mailman id 761021.1170993; Fri, 19 Jul 2024 11:43:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sUm0r-0005nx-H6; Fri, 19 Jul 2024 11:43:01 +0000 Received: by outflank-mailman (input) for mailman id 761021; Fri, 19 Jul 2024 11:33:29 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sUlrd-0004gF-1D for xen-devel@lists.xenproject.org; Fri, 19 Jul 2024 11:33:29 +0000 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b6295d89-45c2-11ef-bbfd-fd08da9f4363; Fri, 19 Jul 2024 13:33:27 +0200 (CEST) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 46JBXONI100164 for ; Fri, 19 Jul 2024 06:33:24 -0500 Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 46JBXO81041731 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 19 Jul 2024 06:33:24 -0500 Received: from DFLE103.ent.ti.com (10.64.6.24) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Fri, 19 Jul 2024 06:33:24 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Fri, 19 Jul 2024 06:33:24 -0500 Received: from localhost (nightbug.dhcp.ti.com [10.24.68.87]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 46JBXNJL076804; Fri, 19 Jul 2024 06:33:24 -0500 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b6295d89-45c2-11ef-bbfd-fd08da9f4363 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1721388805; bh=L0bRkCPaGDdgFautpIKHYtZ+R9TkSjccH9W/hhznknM=; h=From:To:CC:Subject:Date; b=K2QLL3gq0XHLIkiyVcKKJ01FPJOJ/UkBn2LFSbTE2I2m6GtJbJFhduwFZZW2CR7uk 4sS3QXLXTbUMxGIrOkLZXX3a9qQgVeMm1jSgzFunZru/qLBkuowoEsn6sbYWYQJG4+ FfIsGxuEY7q3eqwbRfZhC1s5Rbdw58SzluLiFyn8= From: Amneesh Singh To: CC: Amneesh Singh Subject: [PATCH] drivers: char: omap-uart: add "clock-hz" option Date: Fri, 19 Jul 2024 17:03:13 +0530 Message-ID: <20240719113313.145587-1-a-singh21@ti.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-ZohoMail-DKIM: pass (identity @ti.com) X-ZM-MESSAGEID: 1721389406482116600 Content-Type: text/plain; charset="utf-8" Quite a few TI K3 devices do not have clock-frequency specified in their respective UART nodes. However hard-coding the frequency is not a solution as the function clock input can differ between SoCs. So, similar to com1/com2, let the user pass the frequency as a dtuart option via the bootargs. If not specified it will fallback to the same DT parsing as before. For example, dtuart=3Dserial2:clock-hz=3D48000000 can be a valid bootarg. Signed-off-by: Amneesh Singh --- xen/drivers/char/omap-uart.c | 62 +++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/xen/drivers/char/omap-uart.c b/xen/drivers/char/omap-uart.c index 1079198..660c486 100644 --- a/xen/drivers/char/omap-uart.c +++ b/xen/drivers/char/omap-uart.c @@ -305,33 +305,71 @@ static struct uart_driver __read_mostly omap_uart_dri= ver =3D { .vuart_info =3D omap_vuart_info, }; =20 +static void __init omap_uart_parse_config(struct omap_uart *uart, + const char *config) { + + char options[256]; + char *value, *start =3D options; + + if ( !strcmp(config, "") ) + return; + + strlcpy(options, config, ARRAY_SIZE(options)); + + while (start !=3D NULL) + { + char *name; + + /* Parse next name-value pair. */ + value =3D strsep(&start, ","); + name =3D strsep(&value, "=3D"); + + if ( !strcmp(name, "clock-hz") ) + uart->clock_hz =3D simple_strtoul(value, NULL, 0); + else + printk("WARNING: UART configuration option %s is not supported= \n", + name); + + } +} + static int __init omap_uart_init(struct dt_device_node *dev, const void *data) { const char *config =3D data; struct omap_uart *uart; - u32 clkspec; int res; paddr_t addr, size; =20 - if ( strcmp(config, "") ) - printk("WARNING: UART configuration is not supported\n"); - uart =3D &omap_com; =20 - res =3D dt_property_read_u32(dev, "clock-frequency", &clkspec); - if ( !res ) - { - printk("omap-uart: Unable to retrieve the clock frequency\n"); - return -EINVAL; - } - - uart->clock_hz =3D clkspec; + /* Default configuration. */ + uart->clock_hz =3D 0; uart->baud =3D 115200; uart->data_bits =3D 8; uart->parity =3D UART_PARITY_NONE; uart->stop_bits =3D 1; =20 + /* + * Parse dtuart options. + * Valid options: + * - clock-hz + */ + omap_uart_parse_config(uart, config); + + /* If clock-hz is missing. */ + if ( uart->clock_hz =3D=3D 0 ) + { + u32 clkspec; + res =3D dt_property_read_u32(dev, "clock-frequency", &clkspec); + if ( !res ) + { + printk("omap-uart: Unable to retrieve the clock frequency\n"); + return -EINVAL; + } + uart->clock_hz =3D clkspec; + } + res =3D dt_device_get_paddr(dev, 0, &addr, &size); if ( res ) { --=20 2.34.1