Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1481003rbb; Mon, 26 Feb 2024 10:30:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXJ7qYtdxT4mXht65niwKcInznySXNmq3F85nt4bpuFdHYs0cQ9MwLUjBUIAarUFXb2Ip404GZCrnMG3cPsablKh9J2m8PJzmTjoAQedw== X-Google-Smtp-Source: AGHT+IGXi/1CEgBFaSjTDE0OuN0XJnJcZ1bD7Iia2yElFkt2wjtCRCNVUHkcFsgXeBKAN3GIoWUI X-Received: by 2002:a17:90a:fb4f:b0:299:4cd:69e0 with SMTP id iq15-20020a17090afb4f00b0029904cd69e0mr5946170pjb.0.1708972212650; Mon, 26 Feb 2024 10:30:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708972212; cv=pass; d=google.com; s=arc-20160816; b=EgV9Pn6IM9n8kt0QLG43F1m7U6gU6zXJEuIx/FGqJrwpH+zQAsDWnyYDGrOaPLa2R7 2nEY99m9/xCa/Ouogjbiv2lWDlzSnS5GDyo8yef2ZqeA0a/dx1nhbKbQLNzAmIrRKFFC diqV/7kW1QJoxvgj6FkAALgJftDXfwH0AqzauYWVmpjxap1k5sTHWG7BqJBeC8PXysHG tSJwMdGR0hoTtqssOrrikUNvy4W01OV6ScUsjsL6onC9cpkpTXcjXrp8jX+DMiNx8JFK Ro0IwAN+3ge+Q/WuWJdDHHq7rirXFObEiHhDutcX+TkEqvo3pwVXc9S4hdEBpd4YCo1J hwOA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=egS3YHbo9nyonkHpkEkBcrdlsZO3ugRdoO9vZoooh08=; fh=xSGBIHWd5RaiKxDKjJ9wuXs6bQZHuqbCRoo49Bl7JGU=; b=SOpmkbGvNuYnNb4WAw0L1QwQsL65FuTlouptVhsgCSXuK/nO2W9Umw9u9ykiQaI5OH kzChdgtQM1IbSpuoQOIRR14j7cXKIBPRW9pQA/6d2vIw5e7w6g0M7H9ZnjnHr+GRhxrc sFneXv8THO8Lmu7KDJCuJQcVLjdTvyT/0NgNX4PSPz5L48sitGWbrRovOELFaCziLAVO DdmevWWNTffpLXWHm7EWp3hQh1xTFxE5qNqSdzWA/2xBpHA6+ZCGuZhoY70jv0rU7OIa TObAtBjriIvkbu00D1B+pFSv8QkE8R/Fi2ER+y4Ju71it0BVNKOnSfW7PDbiSFhbBgi+ my9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QQe6vPHG; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-81604-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81604-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d21-20020a17090ab31500b0029aa8f9ccbasi3408781pjr.5.2024.02.26.10.30.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 10:30:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81604-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QQe6vPHG; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-81604-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81604-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 9450AB23932 for ; Mon, 26 Feb 2024 14:25:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 876FF12AAC3; Mon, 26 Feb 2024 14:25:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="QQe6vPHG" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D32B41292F9; Mon, 26 Feb 2024 14:25:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957526; cv=none; b=qLMz7TnrE61lXd9LqFU+zcLxXAM0f4jFxwDqc4HJNhgXxHRHSU36ZDld6axgw45vk38F9ilv/2FmNgKfXZz81B9UiG07BPGGuapz4aisbQx181Gcy5KIHJx0p/E07tVUWATzYylVgMkwfjZps03LbE/vnWbFs2HQxztfwcmGamw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708957526; c=relaxed/simple; bh=epusIY1XMLW5yDgqCMw/7B8Ke39NBboPe91THB/uUvU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RSp1kTO6QREs10TgDIb0K44Xnsk9MgqcY4C+KdR4NOZO9YAebYFtvKB0hMoypUzlacODBlY/S3UFKhinTslWXxsW2Wt8RbTfJRhXhdLMkXL7G/jjwO68G6MB9fT1afV5hibnhC4Swir5uJs+8PMmLYc+6ocnutwsAZpCoAVnOzU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=QQe6vPHG; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708957525; x=1740493525; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=epusIY1XMLW5yDgqCMw/7B8Ke39NBboPe91THB/uUvU=; b=QQe6vPHG8FBUbok2w0cv/Hsh9KqPn574GZcB0p6xFSCiYHFNVw/seIBG 4MAZO22nGUB08EbTtAPb/JaXWd2Vyb2XuD03owK/y9Oec7I2VkpPFt6ui bMNyfJg4UFhL8Ai1746x/QpF7xilAqckNhUjqqifkDYmBOhZn1sTxZvxT sE9N4yMLjtlUTvnwkNWxW7pTyZ0oJQ7lPxSWn6RBqQkv7Umk9FD+Kn3lm rs8TuE0mooSOt9fFueY63TZhrOvlV+3XxlrQBmUKNMwqc21Kjjma/mR2b ymFW7VBLUX09EZjQaxcrpameUbs+Aaahp0pP8TgjcUxYUB5sRTl8tJbtN A==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="3375130" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="3375130" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 06:25:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="937030140" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="937030140" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 26 Feb 2024 06:25:17 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 348304C1; Mon, 26 Feb 2024 16:25:16 +0200 (EET) From: Andy Shevchenko To: Greg Kroah-Hartman , Andy Shevchenko , Thomas Gleixner , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-rpi-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-tegra@vger.kernel.org Cc: Jiri Slaby , Joel Stanley , Andrew Jeffery , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Al Cooper , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Paul Cercueil , Vladimir Zapolskiy , Thierry Reding , Jonathan Hunter , Kunihiko Hayashi , Masami Hiramatsu , Andi Shyti Subject: [PATCH v2 04/14] serial: 8250_aspeed_vuart: Switch to use uart_read_port_properties() Date: Mon, 26 Feb 2024 16:19:20 +0200 Message-ID: <20240226142514.1485246-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1.gbec44491f096 In-Reply-To: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> References: <20240226142514.1485246-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Since we have now a common helper to read port properties use it instead of sparse home grown solution. Reviewed-by: Andi Shyti Signed-off-by: Andy Shevchenko Reviewed-by: Andrew Jeffery --- drivers/tty/serial/8250/8250_aspeed_vuart.c | 50 +++++++-------------- 1 file changed, 15 insertions(+), 35 deletions(-) diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c b/drivers/tty/serial/8250/8250_aspeed_vuart.c index 8c2aaf7af7b7..2a4bc39b11af 100644 --- a/drivers/tty/serial/8250/8250_aspeed_vuart.c +++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c @@ -419,8 +419,8 @@ static int aspeed_vuart_probe(struct platform_device *pdev) struct aspeed_vuart *vuart; struct device_node *np; struct resource *res; - u32 clk, prop, sirq[2]; int rc, sirq_polarity; + u32 prop, sirq[2]; struct clk *vclk; np = pdev->dev.of_node; @@ -447,53 +447,35 @@ static int aspeed_vuart_probe(struct platform_device *pdev) port.port.status = UPSTAT_SYNC_FIFO; port.port.dev = &pdev->dev; port.port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE); + port.port.flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_FIXED_PORT | UPF_FIXED_TYPE | + UPF_NO_THRE_TEST; port.bugs |= UART_BUG_TXRACE; rc = sysfs_create_group(&vuart->dev->kobj, &aspeed_vuart_attr_group); if (rc < 0) return rc; - if (of_property_read_u32(np, "clock-frequency", &clk)) { + rc = uart_read_port_properties(&port.port, true); + if (rc) + goto err_sysfs_remove; + + /* Get clk rate through clk driver if present */ + if (!port.port.uartclk) { vclk = devm_clk_get_enabled(dev, NULL); if (IS_ERR(vclk)) { rc = dev_err_probe(dev, PTR_ERR(vclk), "clk or clock-frequency not defined\n"); goto err_sysfs_remove; } - clk = clk_get_rate(vclk); + port.port.uartclk = clk_get_rate(vclk); } /* If current-speed was set, then try not to change it. */ if (of_property_read_u32(np, "current-speed", &prop) == 0) - port.port.custom_divisor = clk / (16 * prop); + port.port.custom_divisor = port.port.uartclk / (16 * prop); - /* Check for shifted address mapping */ - if (of_property_read_u32(np, "reg-offset", &prop) == 0) - port.port.mapbase += prop; - - /* Check for registers offset within the devices address range */ - if (of_property_read_u32(np, "reg-shift", &prop) == 0) - port.port.regshift = prop; - - /* Check for fifo size */ - if (of_property_read_u32(np, "fifo-size", &prop) == 0) - port.port.fifosize = prop; - - /* Check for a fixed line number */ - rc = of_alias_get_id(np, "serial"); - if (rc >= 0) - port.port.line = rc; - - port.port.irq = irq_of_parse_and_map(np, 0); port.port.handle_irq = aspeed_vuart_handle_irq; - port.port.iotype = UPIO_MEM; port.port.type = PORT_ASPEED_VUART; - port.port.uartclk = clk; - port.port.flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP - | UPF_FIXED_PORT | UPF_FIXED_TYPE | UPF_NO_THRE_TEST; - - if (of_property_read_bool(np, "no-loopback-test")) - port.port.flags |= UPF_SKIP_TEST; if (port.port.fifosize) port.capabilities = UART_CAP_FIFO; @@ -503,7 +485,7 @@ static int aspeed_vuart_probe(struct platform_device *pdev) rc = serial8250_register_8250_port(&port); if (rc < 0) - goto err_clk_disable; + goto err_sysfs_remove; vuart->line = rc; vuart->port = serial8250_get_port(vuart->line); @@ -529,7 +511,7 @@ static int aspeed_vuart_probe(struct platform_device *pdev) rc = aspeed_vuart_set_lpc_address(vuart, prop); if (rc < 0) { dev_err_probe(dev, rc, "invalid value in aspeed,lpc-io-reg property\n"); - goto err_clk_disable; + goto err_sysfs_remove; } rc = of_property_read_u32_array(np, "aspeed,lpc-interrupts", sirq, 2); @@ -541,14 +523,14 @@ static int aspeed_vuart_probe(struct platform_device *pdev) rc = aspeed_vuart_set_sirq(vuart, sirq[0]); if (rc < 0) { dev_err_probe(dev, rc, "invalid sirq number in aspeed,lpc-interrupts property\n"); - goto err_clk_disable; + goto err_sysfs_remove; } sirq_polarity = aspeed_vuart_map_irq_polarity(sirq[1]); if (sirq_polarity < 0) { rc = dev_err_probe(dev, sirq_polarity, "invalid sirq polarity in aspeed,lpc-interrupts property\n"); - goto err_clk_disable; + goto err_sysfs_remove; } aspeed_vuart_set_sirq_polarity(vuart, sirq_polarity); @@ -559,8 +541,6 @@ static int aspeed_vuart_probe(struct platform_device *pdev) return 0; -err_clk_disable: - irq_dispose_mapping(port.port.irq); err_sysfs_remove: sysfs_remove_group(&vuart->dev->kobj, &aspeed_vuart_attr_group); return rc; -- 2.43.0.rc1.1.gbec44491f096