From patchwork Wed Jun 12 20:11:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alper Nebi Yasak X-Patchwork-Id: 13695530 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B5493C27C53 for ; Wed, 12 Jun 2024 20:12:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=1eed+2CfpyC5UVd4nAFeDZB/9Ij+Vk+m/v76FicPbdk=; b=weHnbqHyt0Hh//xVnc86QNRdQ7 ynYB6595tfYxpk8fjAcYrFsM9WfdkJ9XqeNEnPPz7xa4n4zgR+LT3V9rvZt8fny3VURD6WNRsrWqY 1CtYKbguqV/77NxeFsohJnVeCRVS+3etdhMDlRUS1UZ2TMdrCm2/7sKJFJUAO1D9oPEQTPFgwP1nQ tDqZvtvngkv1XXHp1QM6mgdpuNWwfQa2cZjlSOpptAgr1f92fVyGbdC8OKR0fHlI9rRSiL9nZ8EhO UnBelFjkd9UaleL1vbVZW1RkdJHbzT2ZkodAv3+tekJRbGWGceNeQ0B4ZLFBzR0PWIqHxcMA4pvjE eNVh+tew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sHUKe-0000000DzO1-0D7z; Wed, 12 Jun 2024 20:12:32 +0000 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sHUKY-0000000DzJk-08cz; Wed, 12 Jun 2024 20:12:28 +0000 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-35f06861ae6so278402f8f.2; Wed, 12 Jun 2024 13:12:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718223140; x=1718827940; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=1eed+2CfpyC5UVd4nAFeDZB/9Ij+Vk+m/v76FicPbdk=; b=DiAMVA1Mn0odjBKbZSXcfULqPJh3wERxSUFYf6Y1Q44dBZVqWzBxy32nuWCCs4JC2Z C0vTK92j+WrTSphdsN42L5rW+Ug2leaQoOuYq/hfKQzJXJhavW4mwE6/AxgX3NcDYe3i aQ2st8MfttldUBPGBIMTHGoHItWKbs1wzphVT/Lb+c0JAupT3GOHp9UYhxJKzGkPLT47 Uu9xTFIZAcNqgEm33BWiYYHBjVey/1Jrt6Qu/MQukTYlJTMuONVERm19Dvc8wXokHcz1 ndE4cseN6SkVqoCs/gc989x8SuX4yXpWWapt1iM3HIAebWfn9sfq9ti9rYcwHANkwpwP 9LNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718223140; x=1718827940; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1eed+2CfpyC5UVd4nAFeDZB/9Ij+Vk+m/v76FicPbdk=; b=VwH1xjLh65BntiY0epXXiXLInmCnVp8S4YfXFYD7Vx1Z5NbhRPgBfUMmYbOd/bZEzW jBAh6J7lPXKjMOloBK7nvQH1Ynn+6KF+zJ3bEQUQtGvSxcA2TRzmZW/E6wrkOgFon1pA +bbWE6kjMKtxz5gNBswLsLawTsuh66TzHLHUFlr31UNFiTxhX2h7r8SwnuRIw6t4YPWC Hx9CW9A/Bw3wWMnP1WADu9dXH/siAkJxxmolWGZ5pJC9VRVzC7Nn1Da/LHAzB6a8/hy3 7dmCh4XnIagpdP5gqkGbBdEk0TtPCjW7YE/9ClsFF2CHArLYMijTjow2KP99cFL2i5uv dZ2w== X-Forwarded-Encrypted: i=1; AJvYcCXQ5/MwbwhtrkEMgXz2pULrIAEyfrp+HaFy+l7Q0M90qFuwTl3I8BXK96r0jL6eG0KKB+tDgJFWEjfWmzEjf9TYGW7ZqaUr3+7TkhvifngwZtzdot5fj6XbvDC1x6OoMhMOdN1HfPNXQXaSIhxR+qTqMTfhesN8cu0= X-Gm-Message-State: AOJu0YybfCB7rGufojbigVQefRaeV470Y+dfmzuSTm6raRNhi2YC2+cG hCmROjOUi/+4q3INEjaKj4GtUkrauiHcVQGU+9Hi2sAJrQUWGmmA X-Google-Smtp-Source: AGHT+IFzhJSmsSeyPWsFkquVLF4ZsYUhdbk+Ko+VxAggBeLczkroAq1sV7RZSMvKVmWBaruhdXyaWg== X-Received: by 2002:a05:600c:4590:b0:421:a1b4:c1d4 with SMTP id 5b1f17b1804b1-422863a8ce8mr28675025e9.13.1718223140088; Wed, 12 Jun 2024 13:12:20 -0700 (PDT) Received: from ALPER-PC.. ([178.233.24.52]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42286fe7670sm38110205e9.6.2024.06.12.13.12.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 13:12:19 -0700 (PDT) From: Alper Nebi Yasak To: AngeloGioacchino Del Regno , linux-mediatek@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Stephen Boyd , Rob Herring , devicetree@vger.kernel.org, Michael Turquette , =?utf-8?q?Uwe_Kleine-K=C3=B6ni?= =?utf-8?q?g?= , Conor Dooley , linux-arm-kernel@lists.infradead.org, Chen-Yu Tsai , Krzysztof Kozlowski , Matthias Brugger , linux-clk@vger.kernel.org, Alper Nebi Yasak Subject: [PATCH RESEND v2 1/2] clk: mediatek: mt8173-infracfg: Handle unallocated infracfg when module Date: Wed, 12 Jun 2024 23:11:00 +0300 Message-ID: <20240612201211.91683-1-alpernebiyasak@gmail.com> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240612_131226_095945_8F8A3640 X-CRM114-Status: GOOD ( 16.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The MT8173 infracfg clock driver does initialization in two steps, via a CLK_OF_DECLARE_DRIVER declaration. However its early init function doesn't get to run when it's built as a module, presumably since it's not loaded by the time it would have been called by of_clk_init(). This causes its second-step probe() to return -ENOMEM when trying to register clocks, as the necessary clock_data struct isn't initialized by the first step. MT2701 and MT6797 clock drivers also use this mechanism, but they try to allocate the necessary clock_data structure if missing in the second step. Mimic that for the MT8173 infracfg clock as well to make it work as a module. Signed-off-by: Alper Nebi Yasak Reviewed-by: AngeloGioacchino Del Regno --- Changes in v2: - Rewrite patch subject for consistency v1: https://lore.kernel.org/lkml/20231108213734.140707-1-alpernebiyasak@gmail.com/ drivers/clk/mediatek/clk-mt8173-infracfg.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) base-commit: 03d44168cbd7fc57d5de56a3730427db758fc7f6 diff --git a/drivers/clk/mediatek/clk-mt8173-infracfg.c b/drivers/clk/mediatek/clk-mt8173-infracfg.c index 2f2f074e231a..ecc8b0063ea5 100644 --- a/drivers/clk/mediatek/clk-mt8173-infracfg.c +++ b/drivers/clk/mediatek/clk-mt8173-infracfg.c @@ -98,7 +98,17 @@ CLK_OF_DECLARE_DRIVER(mtk_infrasys, "mediatek,mt8173-infracfg", static int clk_mt8173_infracfg_probe(struct platform_device *pdev) { struct device_node *node = pdev->dev.of_node; - int r; + int r, i; + + if (!infra_clk_data) { + infra_clk_data = mtk_alloc_clk_data(CLK_INFRA_NR_CLK); + if (!infra_clk_data) + return -ENOMEM; + } else { + for (i = 0; i < CLK_INFRA_NR_CLK; i++) + if (infra_clk_data->hws[i] == ERR_PTR(-EPROBE_DEFER)) + infra_clk_data->hws[i] = ERR_PTR(-ENOENT); + } r = mtk_clk_register_gates(&pdev->dev, node, infra_gates, ARRAY_SIZE(infra_gates), infra_clk_data); From patchwork Wed Jun 12 20:11:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alper Nebi Yasak X-Patchwork-Id: 13695529 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 235BAC27C75 for ; Wed, 12 Jun 2024 20:12:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=L57epYYY3nvfIXWp0G2IWvPKM4CJXDaQCqlGAc5Qu2E=; b=cuLSvDa4nPIYNS4QF7Iejbht6R Tq7uWySSMn5smUwda9KgWElsNP+K5fmuD/VQKCKgUFgQJK8k5gRLrEcRgsO2r8317RQORHcRERRV0 meHA7873T2/bl/6iwUd6BeanV0qp360VIMqEF+iIfA2CLG5gwXfe2tILWOaUwzXI3FBMLJ4PnEhRF wTY3T0+kvy3robfgm+GtthZm3x6qQNE1YxUT+eCs8EjdM4wGAdD0v51c6vBd24kXe3pQZ/wce1Yzs 4Dv1UKNkJ+ZdeadJVR2o+C7r9ViNc+f3Rp54eKDheScJxyoFihBcZ6AZ+dVyUbE2C+fDwArwnKHaT m7LUPIMQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sHUKc-0000000DzMx-2IMj; Wed, 12 Jun 2024 20:12:30 +0000 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sHUKY-0000000DzK2-1xIe; Wed, 12 Jun 2024 20:12:28 +0000 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4217c7eb6b4so3240975e9.2; Wed, 12 Jun 2024 13:12:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718223142; x=1718827942; darn=lists.infradead.org; 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=L57epYYY3nvfIXWp0G2IWvPKM4CJXDaQCqlGAc5Qu2E=; b=j55vSD8Cjw2IHuQ7oO9YekF/71c5GrZXNt8SJnl6OIdewF30b0cZJPfMNirAKUDyc0 XN2vJrSotaPDtAmyEQK8Fulbl00hC2hSkv+GyMNAZTzwZn3fIoRGJNOxX7Qffq+8YgdP Lp3RxE9MBBhXqcqUqgtRDzdqZISQdfDQz8RlpAULs3gHSbo/3nisZzrvm5Jfy82rgJzX ap5eMc+lfVKQDjtgRisiNF5sg6+Oo21C8C/a+p2KJecOeLLDd58P4ixtE1W1ecu/raQ4 FoMI7OVvjN5jwZIDbESZFNaJJkpEzyCrrFHibS5DRmZiAEaD9W1FTxg1Aq++ee2FWvvY FnDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718223142; x=1718827942; 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=L57epYYY3nvfIXWp0G2IWvPKM4CJXDaQCqlGAc5Qu2E=; b=b3V1NnavPVUmxGCF/4j+YeyV8x3Dg4NFT+NYj+OyQMo4Oq2VWTdWBjmamaSIKIXPGi gJP1GnR9slJwQbaODG61qZxGXvtWov+t/9iOsMcFqGNXatUSacTmNy3rv8lc8FKvUNl5 GyumNNbTTUZujNP5W9BTNfJKH5ccTlri2Yd4VYTkJNt/6+s5H91Gx6NmcqXSdwH7YXKB oXivY+sW/ZvGXM5imJoPlyFinOHKnhDPLlMIMnS177ShsYOiJmmZFES13FXm9fGzUuih OI3UWiI6WA/Eqsf7PxTC6W42zRTTnI9yw8fiToy3x5m2abV5DrviR5+o03hRdf4u5Qs/ pHzA== X-Forwarded-Encrypted: i=1; AJvYcCWzJccnNO960vkPGKn9glKJXOKphMxdgItPACeMR/Hf4Q+GBGN83MAC2KOXkDkca1XSzdMc2U26acDPla9C1FUAA92HkXl8FpRTIVg2EkOVnbEoKEIcTBg0MU1RhU6urnbauFo7YODQsXgA+WUUrs5jFi96khIEyjU= X-Gm-Message-State: AOJu0YzCOcThhWP1Isi/9GCLDAbg7252LhpCftXDdKAF52D/2o1RskRt EJJyGR7Jvla+tl4aVwmXHCmCOIZxcRz8SEhpUOXqSeG9iyN3P5C7 X-Google-Smtp-Source: AGHT+IGILVEjmCSzS67jRWgdAuX1q4I+JSG4Yhl0SPgZJBIukT+wdXYEk+gjwPucjvRhmaopkGKifg== X-Received: by 2002:a05:600c:470b:b0:422:52c3:7fe0 with SMTP id 5b1f17b1804b1-422864aef80mr28544245e9.22.1718223142436; Wed, 12 Jun 2024 13:12:22 -0700 (PDT) Received: from ALPER-PC.. ([178.233.24.52]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42286fe7670sm38110205e9.6.2024.06.12.13.12.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 13:12:21 -0700 (PDT) From: Alper Nebi Yasak To: AngeloGioacchino Del Regno , linux-mediatek@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Stephen Boyd , Rob Herring , devicetree@vger.kernel.org, Michael Turquette , =?utf-8?q?Uwe_Kleine-K=C3=B6ni?= =?utf-8?q?g?= , Conor Dooley , linux-arm-kernel@lists.infradead.org, Chen-Yu Tsai , Krzysztof Kozlowski , Matthias Brugger , linux-clk@vger.kernel.org, Alper Nebi Yasak Subject: [PATCH RESEND v2 2/2] arm64: dts: mediatek: mt8173: Fix timer 13 MHz clock description Date: Wed, 12 Jun 2024 23:11:01 +0300 Message-ID: <20240612201211.91683-2-alpernebiyasak@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240612201211.91683-1-alpernebiyasak@gmail.com> References: <20240612201211.91683-1-alpernebiyasak@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240612_131226_536990_4245967E X-CRM114-Status: GOOD ( 15.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org A previous patch fixes an issue with the mt8173-infracfg clock driver when working as a module, but has the side effect of skipping set up of CLK_INFRA_CLK_13M in that case. This clock is used by the timer device. Similar to the MT8183, MT8192, MT8195 and MT8186 cases [1], change the input clock of the timer block a fixed factor divide-by-2 clock that takes the 26 MHz oscillator as its input. Also remove the RTC clock from the timer node while we're here. According to commit 59311b19d7f63 ("clocksource/drivers/timer-mediatek: Add system timer bindings") it is no longer used. [1] https://lore.kernel.org/all/20221201084229.3464449-1-wenst@chromium.org/ Signed-off-by: Alper Nebi Yasak --- Tested on a MT8173 Chromebook. But I'm not sure I understand all of this, so review with a pinch of salt. Changes in v2: - Add this patch arch/arm64/boot/dts/mediatek/mt8173.dtsi | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi index 3458be7f7f61..809b379b6818 100644 --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi @@ -244,6 +244,15 @@ psci { cpu_on = <0x84000003>; }; + clk13m: fixed-factor-clock-13m { + compatible = "fixed-factor-clock"; + #clock-cells = <0>; + clocks = <&clk26m>; + clock-div = <2>; + clock-mult = <1>; + clock-output-names = "clk13m"; + }; + clk26m: oscillator0 { compatible = "fixed-clock"; #clock-cells = <0>; @@ -530,8 +539,7 @@ timer: timer@10008000 { "mediatek,mt6577-timer"; reg = <0 0x10008000 0 0x1000>; interrupts = ; - clocks = <&infracfg CLK_INFRA_CLK_13M>, - <&topckgen CLK_TOP_RTC_SEL>; + clocks = <&clk13m>; }; pwrap: pwrap@1000d000 {