From patchwork Tue Mar 12 19:25:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13590543 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 D2D15C54E5D for ; Tue, 12 Mar 2024 19:25:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References: List-Owner; bh=43WbYsUyEMSwYUMew9I+xS+gUmn4qtwGViGu9fzYGSQ=; b=sii+8G3bewdKTL jv9H+MOZkT+P91az84VebHWFeOg3HRiiV8iZYoE7YcE+vKMRI816TM56K373tR5T14CluxL0RoiUw kL+oa5zqSDl8t0hdZAEOAcm6NMRgeJxNbVzUoiFqR2IdZ6E5ATp+glr3B2rUHyT55BdIys4pWL9Il s0RWSl8UE+OPouchDXLQYgyk9F8ixIcQbgJhTxhVI7z2Xsdlw3CV8cGLEd5U2pf74/+qT/2uaUl4h 3pSF4ssSHmKbSjTljYbU0y6gZgRKuY3BcU+U6SYcnLBPi9ghc698fce4ps7LsJRuvryEXJsFKX25A /p36f/q7OUE+F5xQilJA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk7kc-00000007HQS-2AXN; Tue, 12 Mar 2024 19:25:26 +0000 Received: from mail-oo1-xc2a.google.com ([2607:f8b0:4864:20::c2a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk7kY-00000007HPY-463p for linux-arm-kernel@lists.infradead.org; Tue, 12 Mar 2024 19:25:24 +0000 Received: by mail-oo1-xc2a.google.com with SMTP id 006d021491bc7-5a1aa46c975so129235eaf.3 for ; Tue, 12 Mar 2024 12:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1710271521; x=1710876321; 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=XTNA6eQOgVZeDaw5GSB+YIN/6xC4LtEXiiAUCgqLZn8=; b=fhDwdI6oQ0OVq5ddepIzllN9UhdVhvtegdusmVP+nSTrkQh8tAwXIc/uOcMLv8pdk6 /4YVOj97MS38avh863X4swJZEMGeGaE011jQ+4WLH/KmJWkak2mRa2//S2ZBvUA2k4p+ a2G1UEl3BJkTKPRAH5kgF4ifX2k6BoC/6fT9+fLYn7DTHZ2FVfiltXb0DJ63OwrdOqbN UybxuyS2jIV9C8chJU5QUzCtqYPAyomnvoGnb1y4xeOt5GyF7t4n/gb+ZjWMfCvDrXIO GmqyIgonBQyFfQ8oom4ppU+wGwawuu04Z6NM3tCs8ho3ydEKK3gSZTXoP9jjF9Ojd3qf /ZPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710271521; x=1710876321; 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=XTNA6eQOgVZeDaw5GSB+YIN/6xC4LtEXiiAUCgqLZn8=; b=vXzcVh3Xo8+W9nr4UhJOKjuGR0CwuwKes4PAK1ZL89j/HAwf52tZIp7xkKRpaXS1QK rk4asJlDLUUpDshGY1UAjfta4jVrtuepOxjMh/eYK3eOEAIPvViSX9jdJa3C2SQdkgO8 S21ydEypOxR3sbkNRO5dff0VolUWebReMqjBZnmPltxayNXDCAOngjWuS2s5H6q2k52A 1v8pNgq4e+JpiGa4OS87FVtqQU9d8WJCp0totZ25aGNQPeRDwDcUNe+ynfgSvDlUnM8V kGrAGKDltfzSQxWlb9O06bqUTSsXFvAIeoP/2WraoliI2d+k6SEj5ZMuBW5Aq2JIBv2N VGyg== X-Forwarded-Encrypted: i=1; AJvYcCV/IN4eQlb8HlkFNBTktcCtvyJ3vbbNg4+jRfbOzaH5KrQ3PwzDGX/KbB8os+JCvsxSPxUm/bHjnP36hqpuQvZeqPQ1aPBswOCS/1CKmsJRHcBDLHo= X-Gm-Message-State: AOJu0Yz4DR+bVlsr0RdYV3bzzetpl/Cg8MJfFPWKNOLJLxbBi5Q/e+tt YnANxzbKNlLmIYl8aCSYDfvmpX6Q0dMu//mnAO1aObB7vZOmKSvHaweJh0Lh8UU= X-Google-Smtp-Source: AGHT+IFiOD7raCGAFJ0jxa2JFYqQhVuwra5l6CJlnVTYYffky42xgWMsOYtz4U8W+MEtKqq5d39gvw== X-Received: by 2002:a05:6358:720e:b0:17e:4fc7:d95 with SMTP id h14-20020a056358720e00b0017e4fc70d95mr1605796rwa.17.1710271521355; Tue, 12 Mar 2024 12:25:21 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id p1-20020a63c141000000b005dc389409c1sm6331177pgi.93.2024.03.12.12.25.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 12:25:20 -0700 (PDT) From: Samuel Holland To: Daniel Lezcano , Thomas Gleixner Cc: Samuel Holland , Anup Patel , Chen-Yu Tsai , Jernej Skrabec , Paul Walmsley , Samuel Holland , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-sunxi@lists.linux.dev Subject: [PATCH] clocksource/drivers/timer-sun4i: Partially convert to a platform driver Date: Tue, 12 Mar 2024 12:25:06 -0700 Message-ID: <20240312192519.1602493-1-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240312_122523_095630_9A4686AA X-CRM114-Status: GOOD ( 16.97 ) 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 Commit 8ec99b033147 ("irqchip/sifive-plic: Convert PLIC driver into a platform driver") broke the MMIO timer on the Allwinner D1 SoC because the IRQ domain is no longer available when timer_probe() is called: [ 0.000000] irq: no irq domain found for interrupt-controller@10000000 ! [ 0.000000] Failed to map interrupt for /soc/timer@2050000 [ 0.000000] Failed to initialize '/soc/timer@2050000': -22 Fix this by wrapping the timer initialization in a platform driver. builtin_platform_driver_probe() must be used because the driver uses timer_of_init(), which is marked as __init. Only convert the sun8i variants of the hardware, because some older SoCs still need the timer probed early for sched_clock(). Fixes: 8ec99b033147 ("irqchip/sifive-plic: Convert PLIC driver into a platform driver") Signed-off-by: Samuel Holland --- drivers/clocksource/timer-sun4i.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/clocksource/timer-sun4i.c b/drivers/clocksource/timer-sun4i.c index 7bdcc60ad43c..728dac2baa84 100644 --- a/drivers/clocksource/timer-sun4i.c +++ b/drivers/clocksource/timer-sun4i.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "timer-of.h" @@ -218,9 +219,24 @@ static int __init sun4i_timer_init(struct device_node *node) } TIMER_OF_DECLARE(sun4i, "allwinner,sun4i-a10-timer", sun4i_timer_init); -TIMER_OF_DECLARE(sun8i_a23, "allwinner,sun8i-a23-timer", - sun4i_timer_init); -TIMER_OF_DECLARE(sun8i_v3s, "allwinner,sun8i-v3s-timer", - sun4i_timer_init); TIMER_OF_DECLARE(suniv, "allwinner,suniv-f1c100s-timer", sun4i_timer_init); + +static int __init sun4i_timer_probe(struct platform_device *pdev) +{ + return sun4i_timer_init(dev_of_node(&pdev->dev)); +} + +static const struct of_device_id sun4i_timer_of_match[] = { + { .compatible = "allwinner,sun8i-a23-timer" }, + { .compatible = "allwinner,sun8i-v3s-timer" }, + { /* sentinel */ } +}; + +static struct platform_driver sun4i_timer_driver = { + .driver = { + .name = "sun4i-timer", + .of_match_table = sun4i_timer_of_match, + }, +}; +builtin_platform_driver_probe(sun4i_timer_driver, sun4i_timer_probe);