From nobody Thu Apr 9 18:00:23 2026 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A959942F545 for ; Tue, 3 Mar 2026 17:36:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772559375; cv=none; b=RFFuDJIASdfnvfp39euy2fkS/OQo1t81pMMcW7Y9HXzIRdMpfVYfrQveYfIQwgxVR6raNhC34H2aiZFK+IRWel2Z3hNkH7y/mvSlXzvTj3u8ay/qQKQS2b4cEKlNxHHWueMG7C9bl9n74Mt++V2mBFFtjDz1FlSC6BILuLplbMM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772559375; c=relaxed/simple; bh=fp8nE++navWYOkQ3djT9eJLiAzC5FLM5ImcyELeJg0k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mzIeOuFU6h0UkwDU00Bw87Fj6sjSRSLTSLgNOgOVAHmNrQRk9r/mcT6bSJwzizq/ufP3Y5yNOj/1DjNBB4EnZk4vLsXeTJY6vk4E46o842RcaR2WbRLRpDLYmwd1ieUKeGbCEalRXA8bB62+3N0+GpfZPHzPXQ1RzQAZOfdWlxI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oss.tenstorrent.com; spf=pass smtp.mailfrom=tenstorrent.com; dkim=pass (2048-bit key) header.d=tenstorrent.com header.i=@tenstorrent.com header.b=IticVzwL; arc=none smtp.client-ip=209.85.128.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oss.tenstorrent.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tenstorrent.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tenstorrent.com header.i=@tenstorrent.com header.b="IticVzwL" Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-79800183233so81747897b3.1 for ; Tue, 03 Mar 2026 09:36:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tenstorrent.com; s=google; t=1772559373; x=1773164173; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=0HaqjdpdHc/fQbEY4OtrbjxxM+K8US2OS03rxWtvBv4=; b=IticVzwLf/HdGSvdGuALSW/Mi/xKoodCwx5go/D8Nk6PuF6+P/+muPwo+ru8T+r13T WYqnqDnqitRYX5GzhgPyDnBqsKxl5WZfmcEr44eOXc7fF2I+CmL/6RlRT5EuJtYNAX9p c0ZzZodPXBNDLjxkRKpE4UHeOWfSfdyk7v/XwmFfxqWxYUkFHetNHNaMegLCGHViZtOX f0z6K808EPlMkb8kjazqRxv7bCGrYOVXWQ6o+8VOKNEyC9iopKXUzG56hMqOzL+go7fi +WCm+w6DkcaGTb4lA0mKVaeVd0U1ZzMPCjSfuOD8N9Iso4pdonb/tikyxAqYARl7Evog vUdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772559373; x=1773164173; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=0HaqjdpdHc/fQbEY4OtrbjxxM+K8US2OS03rxWtvBv4=; b=TuI4SZmkoMDZl45QNSsOsQDrFd/v//Sz/4XB2LzvPSY+kRldkLZcWGwhAnhtSemuaJ 1A4j2aKB0Ormq4cIyDkYhXy0an6hMYXLJbcuTvn6lcSMT45V6bHN8+94xHyoTvWXVr/X wtHgTNf/Pbco9+I8KIhU+Pa8kosGAox5QQ9nX1HKSG+O98OfF1mVj6l8bg/HGjkXzd6/ 7yUR+UfCgH2DvFpHcQHgCLDBXJyy8y6mZAG2ajxtAJIh6WcC/tPbdGmlJIbSV8AxEaF3 OhhVPhHSzwVUuRk5DUT+gleC+AZcu+EOl7lov0fR1JsW8HJur3PGnxD9O1jkVaZLsb/l gfmQ== X-Forwarded-Encrypted: i=1; AJvYcCVt5ZDQCk9R+qxb8CyiTbbb5dD6UqEdT19UMEH6KcTdtp0/0/m+ukc420TawCOAGgfOckQtPX9Gj6KbJ7Y=@vger.kernel.org X-Gm-Message-State: AOJu0YzkHQ/QPxCki3xyqXUag101Tdfxc2/f4BICbHIJU1xFi7rmNS7Q /j0nJBd4NsXTGBEji5XjMF5E78AD5Ypc62Wqm1uzpfVoye4IVxydIHwqtaNavPyhXfk= X-Gm-Gg: ATEYQzyJz+hppVmjzjbc4UKPg0MCOGKNgoL3+qdqVpfrU42qLdW36bdHmX7vLBqCvWh y/nyKl1I5AJ0yzjPxzV7STboRgI+ShpczK3zsEP1cT94OlRbpfde7NAF4kiYqfvtPGc4d1ROOb1 0q/c8PAL8lai1fuc75rMGkq3zBEIshR1KVhGPbmcsV0j63p3/6/56CL/GTijiXvAXjO6qfY86bF IRWFpGxEiU5S2YXZqvfc4O8iaNoDU3PB+k14RaYq4yJhxhpJU080liiE1n9NVVCim5k8AkpJ+jI oTNXG3Sz5Eqz6GnIBoQbhiCVPgV8WQg8BrIXv81urMwCl2REvSaKM1aQMThrfAE9MhU3tljBy+i 0xNFKrycsrHUSQoCgjxw9/Dscsu5NoCR6u5OCLJOxyFTflonjZgvicrMaEcqtebJCq/p5ltHz4Q FOrVyq19kTPYXLzQsxEQdKX0hGR7yaYkP6MJ6VgZwSOavbro56B/ohzqxfgF0cnx1RqMPjHblLA kKBKshmFpFGFE8RW+pj X-Received: by 2002:a05:690c:398:b0:794:c2e7:780c with SMTP id 00721157ae682-798bb40fbf1mr25186327b3.30.1772559372686; Tue, 03 Mar 2026 09:36:12 -0800 (PST) Received: from [192.168.5.15] ([12.55.13.134]) by smtp.gmail.com with ESMTPSA id 00721157ae682-79876a8df9bsm64750477b3.1.2026.03.03.09.36.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2026 09:36:12 -0800 (PST) From: Anirudh Srinivasan Date: Tue, 03 Mar 2026 11:36:07 -0600 Subject: [PATCH v7 1/3] dt-bindings: clk: tenstorrent: Add tenstorrent,atlantis-prcm-rcpu Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260303-atlantis-clocks-v7-1-415c9dda086a@oss.tenstorrent.com> References: <20260303-atlantis-clocks-v7-0-415c9dda086a@oss.tenstorrent.com> In-Reply-To: <20260303-atlantis-clocks-v7-0-415c9dda086a@oss.tenstorrent.com> To: Drew Fustini , Joel Stanley , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Turquette , Stephen Boyd , Anirudh Srinivasan , Philipp Zabel Cc: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, joel@jms.id.au, fustini@kernel.org, mpe@kernel.org, mpe@oss.tenstorrent.com, npiggin@oss.tenstorrent.com, agross@kernel.org, agross@oss.tenstorrent.com, bmasney@redhat.com, Krzysztof Kozlowski X-Mailer: b4 0.14.3 Document bindings for Tenstorrent Atlantis PRCM that manages clocks and resets. This block is instantiated multiple times in the SoC. This commit documents the clocks from the RCPU PRCM block. Reviewed-by: Krzysztof Kozlowski Signed-off-by: Anirudh Srinivasan --- .../clock/tenstorrent,atlantis-prcm-rcpu.yaml | 54 +++++++++++ MAINTAINERS | 2 + .../clock/tenstorrent,atlantis-prcm-rcpu.h | 103 +++++++++++++++++= ++++ 3 files changed, 159 insertions(+) diff --git a/Documentation/devicetree/bindings/clock/tenstorrent,atlantis-p= rcm-rcpu.yaml b/Documentation/devicetree/bindings/clock/tenstorrent,atlanti= s-prcm-rcpu.yaml new file mode 100644 index 000000000000..7fa16526efce --- /dev/null +++ b/Documentation/devicetree/bindings/clock/tenstorrent,atlantis-prcm-rcp= u.yaml @@ -0,0 +1,54 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/tenstorrent,atlantis-prcm-rcpu.ya= ml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Tenstorrent Atlantis PRCM (Power, Reset, Clock Management) Module + +maintainers: + - Anirudh Srinivasan + +description: + Multifunctional register block found in Tenstorrent Atlantis SoC whose m= ain + function is to control clocks and resets. This block is instantiated mul= tiple + times in the SoC, each block controls clock and resets for a different + subsystem. RCPU prcm serves low speed IO interfaces. + +properties: + compatible: + enum: + - tenstorrent,atlantis-prcm-rcpu + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + "#clock-cells": + const: 1 + description: + See for valid i= ndices. + + "#reset-cells": + const: 1 + +required: + - compatible + - reg + - clocks + - "#clock-cells" + - "#reset-cells" + +additionalProperties: false + +examples: + - | + clock-controller@a8000000 { + compatible =3D "tenstorrent,atlantis-prcm-rcpu"; + reg =3D <0xa8000000 0x10000>; + clocks =3D <&osc_24m>; + #clock-cells =3D <1>; + #reset-cells =3D <1>; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 55af015174a5..40c179c8de1e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -22809,8 +22809,10 @@ M: Joel Stanley L: linux-riscv@lists.infradead.org S: Maintained T: git https://github.com/tenstorrent/linux.git +F: Documentation/devicetree/bindings/clock/tenstorrent,atlantis-prcm-rcpu.= yaml F: Documentation/devicetree/bindings/riscv/tenstorrent.yaml F: arch/riscv/boot/dts/tenstorrent/ +F: include/dt-bindings/clock/tenstorrent,atlantis-prcm-rcpu.h =20 RISC-V THEAD SoC SUPPORT M: Drew Fustini diff --git a/include/dt-bindings/clock/tenstorrent,atlantis-prcm-rcpu.h b/i= nclude/dt-bindings/clock/tenstorrent,atlantis-prcm-rcpu.h new file mode 100644 index 000000000000..c1c875e016f8 --- /dev/null +++ b/include/dt-bindings/clock/tenstorrent,atlantis-prcm-rcpu.h @@ -0,0 +1,103 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +/* + * Tenstorrent Atlantis PRCM Clock and Reset Indices + * + * Copyright (c) 2026 Tenstorrent + */ + +#ifndef _DT_BINDINGS_ATLANTIS_PRCM_RCPU_H +#define _DT_BINDINGS_ATLANTIS_PRCM_RCPU_H + +/* + * RCPU Domain Clock IDs + */ +#define CLK_RCPU_PLL 0 +#define CLK_RCPU_ROOT 1 +#define CLK_RCPU_DIV2 2 +#define CLK_RCPU_DIV4 3 +#define CLK_RCPU_RTC 4 +#define CLK_SMNDMA0_ACLK 5 +#define CLK_SMNDMA1_ACLK 6 +#define CLK_WDT0_PCLK 7 +#define CLK_WDT1_PCLK 8 +#define CLK_TIMER_PCLK 9 +#define CLK_PVTC_PCLK 10 +#define CLK_PMU_PCLK 11 +#define CLK_MAILBOX_HCLK 12 +#define CLK_SEC_SPACC_HCLK 13 +#define CLK_SEC_OTP_HCLK 14 +#define CLK_TRNG_PCLK 15 +#define CLK_SEC_CRC_HCLK 16 +#define CLK_SMN_HCLK 17 +#define CLK_AHB0_HCLK 18 +#define CLK_SMN_PCLK 19 +#define CLK_SMN_CLK 20 +#define CLK_SCRATCHPAD_CLK 21 +#define CLK_RCPU_CORE_CLK 22 +#define CLK_RCPU_ROM_CLK 23 +#define CLK_OTP_LOAD_CLK 24 +#define CLK_NOC_PLL 25 +#define CLK_NOCC_CLK 26 +#define CLK_NOCC_DIV2 27 +#define CLK_NOCC_DIV4 28 +#define CLK_NOCC_RTC 29 +#define CLK_NOCC_CAN 30 +#define CLK_QSPI_SCLK 31 +#define CLK_QSPI_HCLK 32 +#define CLK_I2C0_PCLK 33 +#define CLK_I2C1_PCLK 34 +#define CLK_I2C2_PCLK 35 +#define CLK_I2C3_PCLK 36 +#define CLK_I2C4_PCLK 37 +#define CLK_UART0_PCLK 38 +#define CLK_UART1_PCLK 39 +#define CLK_UART2_PCLK 40 +#define CLK_UART3_PCLK 41 +#define CLK_UART4_PCLK 42 +#define CLK_SPI0_PCLK 43 +#define CLK_SPI1_PCLK 44 +#define CLK_SPI2_PCLK 45 +#define CLK_SPI3_PCLK 46 +#define CLK_GPIO_PCLK 47 +#define CLK_CAN0_HCLK 48 +#define CLK_CAN0_CLK 49 +#define CLK_CAN1_HCLK 50 +#define CLK_CAN1_CLK 51 +#define CLK_CAN0_TIMER_CLK 52 +#define CLK_CAN1_TIMER_CLK 53 + +/* RCPU domain reset */ +#define RST_SMNDMA0 0 +#define RST_SMNDMA1 1 +#define RST_WDT0 2 +#define RST_WDT1 3 +#define RST_TMR 4 +#define RST_PVTC 5 +#define RST_PMU 6 +#define RST_MAILBOX 7 +#define RST_SPACC 8 +#define RST_OTP 9 +#define RST_TRNG 10 +#define RST_CRC 11 +#define RST_QSPI 12 +#define RST_I2C0 13 +#define RST_I2C1 14 +#define RST_I2C2 15 +#define RST_I2C3 16 +#define RST_I2C4 17 +#define RST_UART0 18 +#define RST_UART1 19 +#define RST_UART2 20 +#define RST_UART3 21 +#define RST_UART4 22 +#define RST_SPI0 23 +#define RST_SPI1 24 +#define RST_SPI2 25 +#define RST_SPI3 26 +#define RST_GPIO 27 +#define RST_CAN0 28 +#define RST_CAN1 29 +#define RST_I2S0 30 +#define RST_I2S1 31 + +#endif /* _DT_BINDINGS_ATLANTIS_PRCM_RCPU_H */ --=20 2.43.0 From nobody Thu Apr 9 18:00:23 2026 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFA3848AE25 for ; Tue, 3 Mar 2026 17:36:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772559378; cv=none; b=VFfvOlyLUu9H2mhs/RYvirhGXp/80Ji660A7GzI+meYvLmEnBcDgs7r5CbumzIPLwBzFYaVAulZm+bQnNyCe6H+iSnvpId5EOntifknPgbDkTkD+YHfy7gj7vAmfmWS35GFpgKNBmzAJiAwjZpQ7LHoVAfmmlCyLJztZBBkcvkM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772559378; c=relaxed/simple; bh=ikU3SYm4fZtzx41B43XT3sQXiHe6rX7H2mkSsOmUHxg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=T4Lmz+wDPlUehW/qSYIckFErWByf76SCKTxjtZBGQHRFXnWVmtF5ztt38GdlPwkF6l1PcxItoyNciCApPtxd/LjHh+sxFmoUq5/Q4OxXh2yU9Gby88TZO8kGVOssP7QHbXH872fF9544nFFYgyzwMA2KrPbUE7g/jGqrBTSg25E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oss.tenstorrent.com; spf=pass smtp.mailfrom=tenstorrent.com; dkim=pass (2048-bit key) header.d=tenstorrent.com header.i=@tenstorrent.com header.b=LguPl6Ff; arc=none smtp.client-ip=209.85.128.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oss.tenstorrent.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tenstorrent.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tenstorrent.com header.i=@tenstorrent.com header.b="LguPl6Ff" Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-798617c0ad5so32176547b3.1 for ; Tue, 03 Mar 2026 09:36:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tenstorrent.com; s=google; t=1772559374; x=1773164174; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=pU1PBZaWQzhkP+Ano32jZ9EnpFmmd1ZMsGzX+u3jJp8=; b=LguPl6FfvETs3UeJXc+axVLa5CXKYEYNB6f7225KuMJFUYYSz1y/idAxd5P0s9Jhf+ x/b2nJqZLbQIQ33xphw0IjXeoDDoKvhZ3X0RrVCA/m5x2YhZzI199izuTm48NaEff8dn bXcxaWa02YFnAu34mL0/798sBZHck6V5N8c7WWuuub166Marz1+4p9ZWVY2P8rvQwCb3 sUd0oAGxhEeYRAVFAxJ8FRan+H8wO+zpkFGxXGe5Q1vdZiDoI6moPSxzdCUTXIDS1F7Q eTb00FXNrNsEo9NuIle1ECQ0CIDnpGEb74AClfZosjnzb/tZRX9H0JocF+RFzMffYzQU 4lBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772559374; x=1773164174; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=pU1PBZaWQzhkP+Ano32jZ9EnpFmmd1ZMsGzX+u3jJp8=; b=umLOfnBeRUWKA8qLvzZNRZjX7/kUBY22TIFEq5lHVRvhEAYHljX4Sv8w/kEk6hCznQ Wg331mw02nSmj8RjelqoBy6p+K0YfzNxOkV1fXILhS3Tzbhs9oPLYRuXtDp7zcqMlChf 9Cw00ASLnG9LKynw9HQdtLMy1iBVvjbOqZ66TSzPnIGaO5vCwqG4J2lIYtyT9EGmqBeD 9aJbrXeedoN8USyT52TE9FcaXHonqd50Gy66Ip7MZuqQhPDeIrk3Ugua+P6EkX6T2/dM aIolQbL1NPZjKtRBlPgp/k7VSmdXdGVtZu2umHdxrJGIWLWUCgNOeUU7nAOS99X6squA IC6A== X-Forwarded-Encrypted: i=1; AJvYcCVe8W8IxGxYL7rWA0gXLtVk+kJhfu6b9sES73NRvSzo326irRb1UiIBKtEGOqYYYhDUuU2mtZNo4Gaj1q8=@vger.kernel.org X-Gm-Message-State: AOJu0Yy5lxAmmuMx1mBzFWiAQwhN7qnFdj0Orp0g20QjMMSQmYPfIEbm WLvfx4hrfZs9886vktZd6PyAmkV6pR5McsbUC1z+rL9sugQr6fxcUrAL+ydrRqpS6cE= X-Gm-Gg: ATEYQzzprqEBQTaXt8T4b05SKsekv5bIhvOW9lzBzP4dsXOH6tC5lrEU5CUp36WQHRl Gu1sahkaHiKjPWTfbeLewovZOvg/GmUmPZ+hVU+ZBnvpwfuWppXu6wgiUqA4SmDwXckXdKKybed F8ge90GfHdLZG2UWVkCu3tm8bqMgkX1Mn3YIGH+blRkG2N7QbpdvDLF0DoZe8iklJOJBWRwtSuS aT8S1gAh46KO9JLq3vBx+xLNRK3bn4xJeuZBFuesaEPqY19pUzT5MOzFPzMBGn8GS9gV2H9SHfh 9Fp8XQvewT6IB/QatrPDLtvvC2WchYy1RLttUz/jw16HDEFbfNIhP7LGKqPRyZldTcCFQzaH/3+ oHZ/sdlE8p4o1njcW9EPoIVRCrY9eaMhbit8/rpTCQnUNwbY2QfSs4WmPCudJl8wTwAfindjOgK 39//HYIHYLMS55uTLVCHRQdIqzm75ZDcI/RFwF0ne0kByXxK5sb+/tb/3sYIF5GMSKaThbSVSlv Jr4nm2SDg== X-Received: by 2002:a05:690c:6a04:b0:798:67f2:92b9 with SMTP id 00721157ae682-7988561b583mr131829257b3.65.1772559373970; Tue, 03 Mar 2026 09:36:13 -0800 (PST) Received: from [192.168.5.15] ([12.55.13.134]) by smtp.gmail.com with ESMTPSA id 00721157ae682-79876a8df9bsm64750477b3.1.2026.03.03.09.36.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2026 09:36:13 -0800 (PST) From: Anirudh Srinivasan Date: Tue, 03 Mar 2026 11:36:08 -0600 Subject: [PATCH v7 2/3] reset: tenstorrent: Add reset controller for Atlantis Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260303-atlantis-clocks-v7-2-415c9dda086a@oss.tenstorrent.com> References: <20260303-atlantis-clocks-v7-0-415c9dda086a@oss.tenstorrent.com> In-Reply-To: <20260303-atlantis-clocks-v7-0-415c9dda086a@oss.tenstorrent.com> To: Drew Fustini , Joel Stanley , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Turquette , Stephen Boyd , Anirudh Srinivasan , Philipp Zabel Cc: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, joel@jms.id.au, fustini@kernel.org, mpe@kernel.org, mpe@oss.tenstorrent.com, npiggin@oss.tenstorrent.com, agross@kernel.org, agross@oss.tenstorrent.com, bmasney@redhat.com, Krzysztof Kozlowski X-Mailer: b4 0.14.3 Adds Atlantis Reset Controller driver, which shares the same regmap as prcm ( clock controller). This version of the reset controller driver covers resets from the RCPU prcm. Reviewed-by: Philipp Zabel Acked-by: Philipp Zabel Signed-off-by: Anirudh Srinivasan --- MAINTAINERS | 1 + drivers/reset/Kconfig | 11 ++ drivers/reset/Makefile | 1 + drivers/reset/reset-tenstorrent-atlantis.c | 173 +++++++++++++++++++++++++= ++++ 4 files changed, 186 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 40c179c8de1e..493d007d3c65 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -22812,6 +22812,7 @@ T: git https://github.com/tenstorrent/linux.git F: Documentation/devicetree/bindings/clock/tenstorrent,atlantis-prcm-rcpu.= yaml F: Documentation/devicetree/bindings/riscv/tenstorrent.yaml F: arch/riscv/boot/dts/tenstorrent/ +F: drivers/reset/reset-tenstorrent-atlantis.c F: include/dt-bindings/clock/tenstorrent,atlantis-prcm-rcpu.h =20 RISC-V THEAD SoC SUPPORT diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig index 7ce151f6a7e4..85ee9da809ee 100644 --- a/drivers/reset/Kconfig +++ b/drivers/reset/Kconfig @@ -315,6 +315,17 @@ config RESET_SUNXI help This enables the reset driver for Allwinner SoCs. =20 +config RESET_TENSTORRENT_ATLANTIS + tristate "Tenstorrent atlantis reset driver" + depends on ARCH_TENSTORRENT || COMPILE_TEST + select AUXILIARY_BUS + default ARCH_TENSTORRENT + help + This enables the driver for the reset controller + present in the Tenstorrent Atlantis SoC. + Enable this option to be able to use hardware + resets on Atalantis based systems. + config RESET_TH1520 tristate "T-HEAD TH1520 reset controller" depends on ARCH_THEAD || COMPILE_TEST diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile index fc0cc99f8514..7c086baeb02a 100644 --- a/drivers/reset/Makefile +++ b/drivers/reset/Makefile @@ -41,6 +41,7 @@ obj-$(CONFIG_RESET_SIMPLE) +=3D reset-simple.o obj-$(CONFIG_RESET_SOCFPGA) +=3D reset-socfpga.o obj-$(CONFIG_RESET_SUNPLUS) +=3D reset-sunplus.o obj-$(CONFIG_RESET_SUNXI) +=3D reset-sunxi.o +obj-$(CONFIG_RESET_TENSTORRENT_ATLANTIS) +=3D reset-tenstorrent-atlantis.o obj-$(CONFIG_RESET_TH1520) +=3D reset-th1520.o obj-$(CONFIG_RESET_TI_SCI) +=3D reset-ti-sci.o obj-$(CONFIG_RESET_TI_SYSCON) +=3D reset-ti-syscon.o diff --git a/drivers/reset/reset-tenstorrent-atlantis.c b/drivers/reset/res= et-tenstorrent-atlantis.c new file mode 100644 index 000000000000..ab8be52fdd5e --- /dev/null +++ b/drivers/reset/reset-tenstorrent-atlantis.c @@ -0,0 +1,173 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Tenstorrent Atlantis PRCM Reset Driver + * + * Copyright (c) 2026 Tenstorrent + */ + +#include +#include +#include +#include + +/* RCPU Reset Register Offsets */ +#define RCPU_BLK_RST_REG 0x001c +#define LSIO_BLK_RST_REG 0x0020 +#define HSIO_BLK_RST_REG 0x000c +#define PCIE_SUBS_RST_REG 0x0000 +#define MM_RSTN_REG 0x0014 + +struct atlantis_reset_data { + u8 bit; + u16 reg; + bool active_low; +}; + +struct atlantis_reset_controller_data { + const struct atlantis_reset_data *reset_data; + size_t count; +}; + +struct atlantis_reset_controller { + struct reset_controller_dev rcdev; + const struct atlantis_reset_controller_data *data; + struct regmap *regmap; +}; + +static inline struct atlantis_reset_controller * +to_atlantis_reset_controller(struct reset_controller_dev *rcdev) +{ + return container_of(rcdev, struct atlantis_reset_controller, rcdev); +} + +#define RESET_DATA(_reg, _bit, _active_low) \ + { \ + .bit =3D _bit, .reg =3D _reg, .active_low =3D _active_low, \ + } + +static const struct atlantis_reset_data atlantis_rcpu_resets[] =3D { + [RST_SMNDMA0] =3D RESET_DATA(RCPU_BLK_RST_REG, 0, true), + [RST_SMNDMA1] =3D RESET_DATA(RCPU_BLK_RST_REG, 1, true), + [RST_WDT0] =3D RESET_DATA(RCPU_BLK_RST_REG, 2, true), + [RST_WDT1] =3D RESET_DATA(RCPU_BLK_RST_REG, 3, true), + [RST_TMR] =3D RESET_DATA(RCPU_BLK_RST_REG, 4, true), + [RST_PVTC] =3D RESET_DATA(RCPU_BLK_RST_REG, 12, true), + [RST_PMU] =3D RESET_DATA(RCPU_BLK_RST_REG, 13, true), + [RST_MAILBOX] =3D RESET_DATA(RCPU_BLK_RST_REG, 14, true), + [RST_SPACC] =3D RESET_DATA(RCPU_BLK_RST_REG, 26, true), + [RST_OTP] =3D RESET_DATA(RCPU_BLK_RST_REG, 28, true), + [RST_TRNG] =3D RESET_DATA(RCPU_BLK_RST_REG, 29, true), + [RST_CRC] =3D RESET_DATA(RCPU_BLK_RST_REG, 30, true), + [RST_QSPI] =3D RESET_DATA(LSIO_BLK_RST_REG, 0, true), + [RST_I2C0] =3D RESET_DATA(LSIO_BLK_RST_REG, 1, true), + [RST_I2C1] =3D RESET_DATA(LSIO_BLK_RST_REG, 2, true), + [RST_I2C2] =3D RESET_DATA(LSIO_BLK_RST_REG, 3, true), + [RST_I2C3] =3D RESET_DATA(LSIO_BLK_RST_REG, 4, true), + [RST_I2C4] =3D RESET_DATA(LSIO_BLK_RST_REG, 5, true), + [RST_UART0] =3D RESET_DATA(LSIO_BLK_RST_REG, 6, true), + [RST_UART1] =3D RESET_DATA(LSIO_BLK_RST_REG, 7, true), + [RST_UART2] =3D RESET_DATA(LSIO_BLK_RST_REG, 8, true), + [RST_UART3] =3D RESET_DATA(LSIO_BLK_RST_REG, 9, true), + [RST_UART4] =3D RESET_DATA(LSIO_BLK_RST_REG, 10, true), + [RST_SPI0] =3D RESET_DATA(LSIO_BLK_RST_REG, 11, true), + [RST_SPI1] =3D RESET_DATA(LSIO_BLK_RST_REG, 12, true), + [RST_SPI2] =3D RESET_DATA(LSIO_BLK_RST_REG, 13, true), + [RST_SPI3] =3D RESET_DATA(LSIO_BLK_RST_REG, 14, true), + [RST_GPIO] =3D RESET_DATA(LSIO_BLK_RST_REG, 15, true), + [RST_CAN0] =3D RESET_DATA(LSIO_BLK_RST_REG, 17, true), + [RST_CAN1] =3D RESET_DATA(LSIO_BLK_RST_REG, 18, true), + [RST_I2S0] =3D RESET_DATA(LSIO_BLK_RST_REG, 19, true), + [RST_I2S1] =3D RESET_DATA(LSIO_BLK_RST_REG, 20, true), + +}; + +static const struct atlantis_reset_controller_data atlantis_rcpu_reset_dat= a =3D { + .reset_data =3D atlantis_rcpu_resets, + .count =3D ARRAY_SIZE(atlantis_rcpu_resets), +}; + +static int atlantis_reset_update(struct reset_controller_dev *rcdev, + unsigned long id, bool assert) +{ + unsigned int val; + struct atlantis_reset_controller *rst =3D + to_atlantis_reset_controller(rcdev); + const struct atlantis_reset_data *data =3D &rst->data->reset_data[id]; + unsigned int mask =3D BIT(data->bit); + struct regmap *regmap =3D rst->regmap; + + if (data->active_low ^ assert) + val =3D mask; + else + val =3D 0; + + return regmap_update_bits(regmap, data->reg, mask, val); +} + +static int atlantis_reset_assert(struct reset_controller_dev *rcdev, + unsigned long id) +{ + return atlantis_reset_update(rcdev, id, true); +} + +static int atlantis_reset_deassert(struct reset_controller_dev *rcdev, + unsigned long id) +{ + return atlantis_reset_update(rcdev, id, false); +} + +static const struct reset_control_ops atlantis_reset_control_ops =3D { + .assert =3D atlantis_reset_assert, + .deassert =3D atlantis_reset_deassert, +}; + +static int +atlantis_reset_controller_register(struct device *dev, + struct atlantis_reset_controller *controller) +{ + struct reset_controller_dev *rcdev =3D &controller->rcdev; + + rcdev->ops =3D &atlantis_reset_control_ops; + rcdev->owner =3D THIS_MODULE; + rcdev->of_node =3D dev->of_node; + rcdev->nr_resets =3D controller->data->count; + + return devm_reset_controller_register(dev, &controller->rcdev); +} +static int atlantis_reset_probe(struct auxiliary_device *adev, + const struct auxiliary_device_id *id) +{ + struct atlantis_reset_controller *controller; + struct device *dev =3D &adev->dev; + struct regmap *regmap; + + regmap =3D dev_get_regmap(dev->parent, NULL); + if (!regmap) + return -ENODEV; + + controller =3D devm_kzalloc(dev, sizeof(*controller), GFP_KERNEL); + if (!controller) + return -ENOMEM; + controller->data =3D + (const struct atlantis_reset_controller_data *)id->driver_data; + controller->regmap =3D regmap; + + return atlantis_reset_controller_register(dev, controller); +} + +static const struct auxiliary_device_id atlantis_reset_ids[] =3D { + { .name =3D "atlantis_prcm.rcpu-reset", + .driver_data =3D (kernel_ulong_t)&atlantis_rcpu_reset_data }, + {}, +}; +MODULE_DEVICE_TABLE(auxiliary, atlantis_reset_ids); + +static struct auxiliary_driver atlantis_reset_driver =3D { + .probe =3D atlantis_reset_probe, + .id_table =3D atlantis_reset_ids, +}; +module_auxiliary_driver(atlantis_reset_driver); + +MODULE_AUTHOR("Anirudh Srinivasan "); +MODULE_DESCRIPTION("Atlantis PRCM reset controller driver"); +MODULE_LICENSE("GPL"); --=20 2.43.0 From nobody Thu Apr 9 18:00:23 2026 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 942AD3EF0B6 for ; Tue, 3 Mar 2026 17:36:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772559379; cv=none; b=cjhVVupLccrneihdxZYs9XoLReMA2Dk0mrbs7y545HnUGw4M7P3qaoOLAtbGsZC8MZ/Y+ru08b3QRzvZ1832QGs/MrhspFgQilDYmEA62yGLlyLFoSzWqqP/5E+UCy8NKxJzV+pe8CEJmIsAPAbqeeQFHrdf1y48aLlTokw5nGI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772559379; c=relaxed/simple; bh=patfAppLq1GMNOXxbx1je9ATXet+qG+8zFxKzKbCys8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ggmd24YSMYdcFQahKauB7GDYIFbcyEKLX9hmWDIYEa+PxBzY3YfsThfC6UNGyzMxhno2BcDq3Co4te8uDVdJGAb2zUDCvGgOYuKZ+KtFzBu4cGeekpeJdr3fgNX+9QhdJLuo2et0lw78eehVc+kGon8dysznXVSACsjErYls590= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oss.tenstorrent.com; spf=pass smtp.mailfrom=tenstorrent.com; dkim=pass (2048-bit key) header.d=tenstorrent.com header.i=@tenstorrent.com header.b=cj5CV7o7; arc=none smtp.client-ip=209.85.128.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oss.tenstorrent.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tenstorrent.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tenstorrent.com header.i=@tenstorrent.com header.b="cj5CV7o7" Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-79898953985so23774937b3.1 for ; Tue, 03 Mar 2026 09:36:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tenstorrent.com; s=google; t=1772559376; x=1773164176; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=P6CG4jxeOqPyrdhx0h1Qv14vdnU+RXbTDafAVWUiuME=; b=cj5CV7o7/TUCMKqDgeCjbhb2x3JqOKm+WojlBIrerwCZU8YreT/AcLpjLMkzs9JAip 2CUxqwFqOvrB+1BQp/VtV8y7IxrSt4Az/jpQttUOpNEk8uwqdwXWcNNR5rZldaN1ocZ1 PsfbW0MM2Xo2Gdrp9a+ucu4JQaRijgEqQWCxB4fH+xARO+uXK2rVKotcYxHBf5YGqevE bxoiejHE8o/kyy0CiLzP5gw88AZHSd5pv1aql1FWVmkzmNEPj7O/M2Irco7V90Z/x2if GWTjEXIYluD0hDz97pB0PqxTXuKfGJnr8b8Jv4RJ0DmOQU9ujuVlfDFY55AMFwOzKeC5 YuEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772559376; x=1773164176; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=P6CG4jxeOqPyrdhx0h1Qv14vdnU+RXbTDafAVWUiuME=; b=EvfjehhoNa+C7wsnfQF5XRxvv5Ym0IzkVrYErsHrYCflZY+KZUUHEt1blQf+FVdrwe xX0P6W2Or2qVQJWAvkqgeLdGqst9HbmjmsR1p1eyjHRIuYSQmG8uXTNGRMrudBXvjycS YSvwrn19nL9kibDjv9VegQcbR0guRJEVFA9qXsi5KCSrrb0AAjwI5tjqg97+k2RiqJ2s mXQlwtsH1HHecwOt1tjGmTi5lJE5x06wlwZ5Cm90f+Tj0Golt13h5vmfFeslXgNRpK2r Jp7Q3V6SjoOHBWhz3eZYXgyURlhLZNstGvGgh1/8oZsXqA78X/xQgEvv+rIuGrK4yG0q p7SA== X-Forwarded-Encrypted: i=1; AJvYcCUS9Jk/BDFvrT2UYyDWxop1by0nrWgslbIdfbf1os9fMISLX5bVIqykaAS57omSCvq1GyI1NC5t8UAArjY=@vger.kernel.org X-Gm-Message-State: AOJu0Ywm5UQdfel2ltTFLm9/E6aAb/sW8baS121MNU+I5EtixKJQItdd zfhzOor0gXxdGNEi8lpd0zNDm4ZPBefTWEhUdrixQsrldOy2RpzOHng882TwzqwpChQ= X-Gm-Gg: ATEYQzxu1s/Ax3WzwY2yCypIPtEJgrFIl6x3+ZdQL/rP+N6lwxhENI9jdHe666VgvMs xvZVijVMI6v8n4NpeXPRpW+aYKhevYmvAowCsgReUBEQbLhTkIeWcO5hBUZot3gPwTnYTje1+dl p04697wIwLhQ03l60CdrYDFXmVrOpR0/E19H7p3qOINd6TNHKUm/GXjwIAydN+p8mJ6Jw3Vi3CW Q6yNjBGfIuOKXo2cq+ILpFy1/U5pzuIbkLOoU0KWEg2ROLoqUw5oY5hSr0VMMT0YveisD69JLmH kGj4Cz206xHbpi8mtBTTm7sJifWBC5pMy8uOCHLMD4vQFAlQAuu1Kpi+Ly/leXuSYVpc/iwxwV2 A6gx6OaIYymo8T72yS/o0tQFtzt4yBki7d31MAsBiFi2/XX+O5nXOa5He8vtUipbLVJOuYUsQT8 mjaMzB/OQ8t5D9ZVvaCSkmBhZjQIKbb7YxbokvJ5XWOlMA8JtXz2g3UOHWEgWdv5VWfp4gUx11r OX7dBjd7g== X-Received: by 2002:a05:690c:386:b0:794:d887:726e with SMTP id 00721157ae682-79885609d5bmr150892757b3.57.1772559375501; Tue, 03 Mar 2026 09:36:15 -0800 (PST) Received: from [192.168.5.15] ([12.55.13.134]) by smtp.gmail.com with ESMTPSA id 00721157ae682-79876a8df9bsm64750477b3.1.2026.03.03.09.36.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Mar 2026 09:36:15 -0800 (PST) From: Anirudh Srinivasan Date: Tue, 03 Mar 2026 11:36:09 -0600 Subject: [PATCH v7 3/3] clk: tenstorrent: Add Atlantis clock controller driver Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260303-atlantis-clocks-v7-3-415c9dda086a@oss.tenstorrent.com> References: <20260303-atlantis-clocks-v7-0-415c9dda086a@oss.tenstorrent.com> In-Reply-To: <20260303-atlantis-clocks-v7-0-415c9dda086a@oss.tenstorrent.com> To: Drew Fustini , Joel Stanley , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Michael Turquette , Stephen Boyd , Anirudh Srinivasan , Philipp Zabel Cc: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, joel@jms.id.au, fustini@kernel.org, mpe@kernel.org, mpe@oss.tenstorrent.com, npiggin@oss.tenstorrent.com, agross@kernel.org, agross@oss.tenstorrent.com, bmasney@redhat.com, Krzysztof Kozlowski X-Mailer: b4 0.14.3 Add driver for clock controller in Tenstorrent Atlantis SoC. This version of the driver covers clocks from RCPU subsystem. 5 types of clocks generated by this controller: PLLs (PLLs with bypass functionality and an additional Gate clk at output), Shared Gates (Multiple Gate clks that share an enable bit), standard Muxes, Dividers and Gates. All clocks are implemented using custom clk ops and use the regmap interface associated with the syscon. All clocks are derived from a 24 Mhz oscillator. The reset controller is also setup as an auxiliary device of the clock controller. Signed-off-by: Anirudh Srinivasan --- MAINTAINERS | 1 + drivers/clk/Kconfig | 1 + drivers/clk/Makefile | 1 + drivers/clk/tenstorrent/Kconfig | 14 + drivers/clk/tenstorrent/Makefile | 3 + drivers/clk/tenstorrent/atlantis-prcm.c | 893 ++++++++++++++++++++++++++++= ++++ 6 files changed, 913 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 493d007d3c65..a7783eb0a7de 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -22812,6 +22812,7 @@ T: git https://github.com/tenstorrent/linux.git F: Documentation/devicetree/bindings/clock/tenstorrent,atlantis-prcm-rcpu.= yaml F: Documentation/devicetree/bindings/riscv/tenstorrent.yaml F: arch/riscv/boot/dts/tenstorrent/ +F: drivers/clk/tenstorrent/ F: drivers/reset/reset-tenstorrent-atlantis.c F: include/dt-bindings/clock/tenstorrent,atlantis-prcm-rcpu.h =20 diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig index 3d803b4cf5c1..8cc300b90b5f 100644 --- a/drivers/clk/Kconfig +++ b/drivers/clk/Kconfig @@ -531,6 +531,7 @@ source "drivers/clk/starfive/Kconfig" source "drivers/clk/sunxi/Kconfig" source "drivers/clk/sunxi-ng/Kconfig" source "drivers/clk/tegra/Kconfig" +source "drivers/clk/tenstorrent/Kconfig" source "drivers/clk/thead/Kconfig" source "drivers/clk/stm32/Kconfig" source "drivers/clk/ti/Kconfig" diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index f7bce3951a30..f52cf3ac64fc 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile @@ -155,6 +155,7 @@ obj-y +=3D starfive/ obj-$(CONFIG_ARCH_SUNXI) +=3D sunxi/ obj-y +=3D sunxi-ng/ obj-$(CONFIG_ARCH_TEGRA) +=3D tegra/ +obj-y +=3D tenstorrent/ obj-$(CONFIG_ARCH_THEAD) +=3D thead/ obj-y +=3D ti/ obj-$(CONFIG_CLK_UNIPHIER) +=3D uniphier/ diff --git a/drivers/clk/tenstorrent/Kconfig b/drivers/clk/tenstorrent/Kcon= fig new file mode 100644 index 000000000000..9d4391eeeae0 --- /dev/null +++ b/drivers/clk/tenstorrent/Kconfig @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0-only + +config TENSTORRENT_ATLANTIS_PRCM + tristate "Support for Tenstorrent Atlantis PRCM Clock Controller" + depends on ARCH_TENSTORRENT || COMPILE_TEST + default ARCH_TENSTORRENT + select REGMAP_MMIO + select AUXILIARY_BUS + select MFD_SYSCON + help + Say yes here to support the different clock + controllers found in the Tenstorrent Atlantis SoC. + This includes the clocks from the RCPU, HSIO, MMIO + and PCIE domain. diff --git a/drivers/clk/tenstorrent/Makefile b/drivers/clk/tenstorrent/Mak= efile new file mode 100644 index 000000000000..95d87bac7bf5 --- /dev/null +++ b/drivers/clk/tenstorrent/Makefile @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_TENSTORRENT_ATLANTIS_PRCM) +=3D atlantis-prcm.o diff --git a/drivers/clk/tenstorrent/atlantis-prcm.c b/drivers/clk/tenstorr= ent/atlantis-prcm.c new file mode 100644 index 000000000000..b0a8e3526901 --- /dev/null +++ b/drivers/clk/tenstorrent/atlantis-prcm.c @@ -0,0 +1,893 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Tenstorrent Atlantis PRCM Clock Driver + * + * Copyright (c) 2026 Tenstorrent + */ + +#include +#include +#include +#include +#include +#include +#include + +/* RCPU Clock Register Offsets */ +#define RCPU_PLL_CFG_REG 0x0000 +#define RCPU_NOCC_PLL_CFG_REG 0x0004 +#define RCPU_NOCC_CLK_CFG_REG 0x0008 +#define RCPU_DIV_CFG_REG 0x000C +#define RCPU_BLK_CG_REG 0x0014 +#define LSIO_BLK_CG_REG 0x0018 +#define PLL_RCPU_EN_REG 0x011c +#define PLL_NOCC_EN_REG 0x0120 +#define BUS_CG_REG 0x01FC + +/* PLL Bit Definitions */ +#define PLL_CFG_EN_BIT BIT(0) +#define PLL_CFG_BYPASS_BIT BIT(1) +#define PLL_CFG_REFDIV_MASK GENMASK(7, 2) +#define PLL_CFG_REFDIV_SHIFT 2 +#define PLL_CFG_POSTDIV1_MASK GENMASK(10, 8) +#define PLL_CFG_POSTDIV1_SHIFT 8 +#define PLL_CFG_POSTDIV2_MASK GENMASK(13, 11) +#define PLL_CFG_POSTDIV2_SHIFT 11 +#define PLL_CFG_FBDIV_MASK GENMASK(25, 14) +#define PLL_CFG_FBDIV_SHIFT 14 +#define PLL_CFG_LKDT_BIT BIT(30) +#define PLL_CFG_LOCK_BIT BIT(31) +#define PLL_LOCK_TIMEOUT_US 1000 +#define PLL_BYPASS_WAIT_US 500 + +struct atlantis_clk_common { + int clkid; + struct regmap *regmap; + struct clk_hw hw; +}; + +static inline struct atlantis_clk_common * +hw_to_atlantis_clk_common(struct clk_hw *hw) +{ + return container_of(hw, struct atlantis_clk_common, hw); +} + +struct atlantis_clk_mux_config { + u8 shift; + u8 width; + u32 reg_offset; +}; + +struct atlantis_clk_mux { + struct atlantis_clk_common common; + struct atlantis_clk_mux_config config; +}; + +struct atlantis_clk_gate_config { + u32 reg_offset; + u32 enable; +}; + +struct atlantis_clk_gate { + struct atlantis_clk_common common; + struct atlantis_clk_gate_config config; +}; + +struct atlantis_clk_divider_config { + u8 shift; + u8 width; + u32 flags; + u32 reg_offset; +}; + +struct atlantis_clk_divider { + struct atlantis_clk_common common; + struct atlantis_clk_divider_config config; +}; + +struct atlantis_clk_pll_config { + u32 tbl_num; + u32 reg_offset; + u32 en_reg_offset; + u32 cg_reg_offset; + u32 cg_reg_enable; +}; + +/* Models a PLL with Bypass Functionality and Enable Bit + an optional Gat= e Clock at it's output */ +struct atlantis_clk_pll { + struct atlantis_clk_common common; + struct atlantis_clk_pll_config config; +}; + +struct atlantis_clk_gate_shared_config { + u32 reg_offset; + u32 enable; + unsigned int *share_count; + spinlock_t *refcount_lock; +}; + +struct atlantis_clk_gate_shared { + struct atlantis_clk_common common; + struct atlantis_clk_gate_shared_config config; +}; + +struct atlantis_clk_fixed_factor_config { + unsigned int mult; + unsigned int div; +}; + +struct atlantis_clk_fixed_factor { + struct atlantis_clk_fixed_factor_config config; + struct atlantis_clk_common common; +}; + +static inline struct atlantis_clk_mux *hw_to_atlantis_clk_mux(struct clk_h= w *hw) +{ + struct atlantis_clk_common *common =3D hw_to_atlantis_clk_common(hw); + + return container_of(common, struct atlantis_clk_mux, common); +} + +static inline struct atlantis_clk_gate * +hw_to_atlantis_clk_gate(struct clk_hw *hw) +{ + struct atlantis_clk_common *common =3D hw_to_atlantis_clk_common(hw); + + return container_of(common, struct atlantis_clk_gate, common); +} + +static inline struct atlantis_clk_divider * +hw_to_atlantis_clk_divider(struct clk_hw *hw) +{ + struct atlantis_clk_common *common =3D hw_to_atlantis_clk_common(hw); + + return container_of(common, struct atlantis_clk_divider, common); +} + +static inline struct atlantis_clk_pll *hw_to_atlantis_pll(struct clk_hw *h= w) +{ + struct atlantis_clk_common *common =3D hw_to_atlantis_clk_common(hw); + + return container_of(common, struct atlantis_clk_pll, common); +} + +static inline struct atlantis_clk_gate_shared * +hw_to_atlantis_clk_gate_shared(struct clk_hw *hw) +{ + struct atlantis_clk_common *common =3D hw_to_atlantis_clk_common(hw); + + return container_of(common, struct atlantis_clk_gate_shared, common); +} + +static inline struct atlantis_clk_fixed_factor * +hw_to_atlantis_clk_fixed_factor(struct clk_hw *hw) +{ + struct atlantis_clk_common *common =3D hw_to_atlantis_clk_common(hw); + + return container_of(common, struct atlantis_clk_fixed_factor, common); +} + +static u8 atlantis_clk_mux_get_parent(struct clk_hw *hw) +{ + struct atlantis_clk_mux *mux =3D hw_to_atlantis_clk_mux(hw); + u32 val; + + regmap_read(mux->common.regmap, mux->config.reg_offset, &val); + val >>=3D mux->config.shift; + val &=3D (BIT(mux->config.width) - 1); + + return val; +} + +static int atlantis_clk_mux_set_parent(struct clk_hw *hw, u8 index) +{ + struct atlantis_clk_mux *mux =3D hw_to_atlantis_clk_mux(hw); + u32 val =3D index; + + return regmap_update_bits(mux->common.regmap, mux->config.reg_offset, + (BIT(mux->config.width) - 1) + << mux->config.shift, + val << mux->config.shift); +} + +static int atlantis_clk_mux_determine_rate(struct clk_hw *hw, + struct clk_rate_request *req) +{ + return clk_mux_determine_rate_flags(hw, req, hw->init->flags); +} + +static const struct clk_ops atlantis_clk_mux_ops =3D { + .get_parent =3D atlantis_clk_mux_get_parent, + .set_parent =3D atlantis_clk_mux_set_parent, + .determine_rate =3D atlantis_clk_mux_determine_rate, +}; + +static void atlantis_clk_gate_endisable(struct clk_hw *hw, int enable) +{ + struct atlantis_clk_gate *gate =3D hw_to_atlantis_clk_gate(hw); + u32 val; + + if (enable) + val =3D gate->config.enable; + else + val =3D ~(gate->config.enable); + + regmap_update_bits(gate->common.regmap, gate->config.reg_offset, + gate->config.enable, val); +} + +static int atlantis_clk_gate_enable(struct clk_hw *hw) +{ + atlantis_clk_gate_endisable(hw, 1); + + return 0; +} + +static void atlantis_clk_gate_disable(struct clk_hw *hw) +{ + atlantis_clk_gate_endisable(hw, 0); +} + +static int atlantis_clk_gate_is_enabled(struct clk_hw *hw) +{ + struct atlantis_clk_gate *gate =3D hw_to_atlantis_clk_gate(hw); + u32 val; + + regmap_read(gate->common.regmap, gate->config.reg_offset, &val); + + val &=3D gate->config.enable; + + return !!val; +} + +static const struct clk_ops atlantis_clk_gate_ops =3D { + .enable =3D atlantis_clk_gate_enable, + .disable =3D atlantis_clk_gate_disable, + .is_enabled =3D atlantis_clk_gate_is_enabled, +}; + +static unsigned long atlantis_clk_divider_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct atlantis_clk_divider *divider =3D hw_to_atlantis_clk_divider(hw); + u32 val; + + regmap_read(divider->common.regmap, divider->config.reg_offset, &val); + + val >>=3D divider->config.shift; + val &=3D ((1 << (divider->config.width)) - 1); + + return DIV_ROUND_UP_ULL((u64)parent_rate, val + 1); +} + +static const struct clk_ops atlantis_clk_divider_ops =3D { + .recalc_rate =3D atlantis_clk_divider_recalc_rate, +}; + +static unsigned long +atlantis_clk_fixed_factor_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct atlantis_clk_fixed_factor *factor =3D + hw_to_atlantis_clk_fixed_factor(hw); + unsigned long long rate; + + rate =3D (unsigned long long)parent_rate * factor->config.mult; + do_div(rate, factor->config.div); + return (unsigned long)rate; +} + +static const struct clk_ops atlantis_clk_fixed_factor_ops =3D { + .recalc_rate =3D atlantis_clk_fixed_factor_recalc_rate, +}; + +static int atlantis_clk_pll_is_enabled(struct clk_hw *hw) +{ + struct atlantis_clk_pll *pll =3D hw_to_atlantis_pll(hw); + u32 val, en_val, cg_val; + + regmap_read(pll->common.regmap, pll->config.reg_offset, &val); + regmap_read(pll->common.regmap, pll->config.en_reg_offset, &en_val); + regmap_read(pll->common.regmap, pll->config.cg_reg_offset, &cg_val); + + /* Check if PLL is powered on, locked, not bypassed and Gate clk is enabl= ed */ + return !!(en_val & PLL_CFG_EN_BIT) && !!(val & PLL_CFG_LOCK_BIT) && + (!pll->config.cg_reg_enable || (cg_val & pll->config.cg_reg_enable= )) && + !(val & PLL_CFG_BYPASS_BIT); +} + +static int atlantis_clk_pll_enable(struct clk_hw *hw) +{ + struct atlantis_clk_pll *pll =3D hw_to_atlantis_pll(hw); + u32 val, en_val, cg_val; + int ret; + + regmap_read(pll->common.regmap, pll->config.reg_offset, &val); + regmap_read(pll->common.regmap, pll->config.en_reg_offset, &en_val); + regmap_read(pll->common.regmap, pll->config.cg_reg_offset, &cg_val); + + /* Check if PLL is already enabled, locked, not bypassed and Gate clk is = enabled */ + if ((en_val & PLL_CFG_EN_BIT) && (val & PLL_CFG_LOCK_BIT) && + (!pll->config.cg_reg_enable || (cg_val & pll->config.cg_reg_enable)) = && + !(val & PLL_CFG_BYPASS_BIT)) { + return 0; + } + + /* Step 1: Set bypass mode first */ + regmap_update_bits(pll->common.regmap, pll->config.reg_offset, + PLL_CFG_BYPASS_BIT, PLL_CFG_BYPASS_BIT); + + /* Step 2: Enable PLL (clear then set power bit) */ + regmap_update_bits(pll->common.regmap, pll->config.en_reg_offset, + PLL_CFG_EN_BIT, 0); + + regmap_update_bits(pll->common.regmap, pll->config.en_reg_offset, + PLL_CFG_EN_BIT, PLL_CFG_EN_BIT); + + /* Step 3: Wait for PLL lock */ + ret =3D regmap_read_poll_timeout(pll->common.regmap, + pll->config.reg_offset, val, + val & PLL_CFG_LOCK_BIT, 10, + PLL_BYPASS_WAIT_US); + if (ret) { + pr_err("PLL failed to lock within timeout\n"); + return ret; + } + + /* Step 4: Switch from bypass to PLL output */ + regmap_update_bits(pll->common.regmap, pll->config.reg_offset, + PLL_CFG_BYPASS_BIT, 0); + + /* Enable Gate clk at PLL Output */ + return regmap_update_bits(pll->common.regmap, pll->config.cg_reg_offset, + pll->config.cg_reg_enable, + pll->config.cg_reg_enable); +} + +static void atlantis_clk_pll_disable(struct clk_hw *hw) +{ + struct atlantis_clk_pll *pll =3D hw_to_atlantis_pll(hw); + + /* Step 1: Switch to bypass mode before disabling */ + regmap_update_bits(pll->common.regmap, pll->config.reg_offset, + PLL_CFG_BYPASS_BIT, PLL_CFG_BYPASS_BIT); + /* Step 2: Power down PLL */ + regmap_update_bits(pll->common.regmap, pll->config.en_reg_offset, + PLL_CFG_EN_BIT, 0); +} + +static unsigned long atlantis_clk_pll_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct atlantis_clk_pll *pll =3D hw_to_atlantis_pll(hw); + + u32 val, refdiv, fbdiv, postdiv1, postdiv2; + u64 fout; + + regmap_read(pll->common.regmap, pll->config.reg_offset, &val); + + if (val & PLL_CFG_BYPASS_BIT) + return parent_rate; + + refdiv =3D FIELD_GET(PLL_CFG_REFDIV_MASK, val); + fbdiv =3D FIELD_GET(PLL_CFG_FBDIV_MASK, val); + postdiv1 =3D FIELD_GET(PLL_CFG_POSTDIV1_MASK, val); + postdiv2 =3D FIELD_GET(PLL_CFG_POSTDIV2_MASK, val); + + if (!refdiv) + refdiv =3D 1; + if (!postdiv1) + postdiv1 =3D 1; + if (!postdiv2) + postdiv2 =3D 1; + if (!fbdiv) + return 0; + + fout =3D div64_u64((u64)parent_rate * fbdiv, + refdiv * postdiv1 * postdiv2); + + return fout; +} + +static const struct clk_ops atlantis_clk_pll_ops =3D { + .enable =3D atlantis_clk_pll_enable, + .disable =3D atlantis_clk_pll_disable, + .recalc_rate =3D atlantis_clk_pll_recalc_rate, + .is_enabled =3D atlantis_clk_pll_is_enabled, +}; + +static int atlantis_clk_gate_shared_enable(struct clk_hw *hw) +{ + struct atlantis_clk_gate_shared *gate =3D + hw_to_atlantis_clk_gate_shared(hw); + bool need_enable; + u32 reg; + + scoped_guard(spinlock_irqsave, gate->config.refcount_lock) + { + need_enable =3D (*gate->config.share_count)++ =3D=3D 0; + if (need_enable) { + regmap_read(gate->common.regmap, + gate->config.reg_offset, ®); + reg |=3D gate->config.enable; + regmap_write(gate->common.regmap, + gate->config.reg_offset, reg); + } + } + + if (need_enable) { + regmap_read(gate->common.regmap, gate->config.reg_offset, ®); + + if (!(reg & gate->config.enable)) { + pr_warn("%s: gate enable %d failed to enable\n", + clk_hw_get_name(hw), gate->config.enable); + return -EIO; + } + } + + return 0; +} + +static void atlantis_clk_gate_shared_disable(struct clk_hw *hw) +{ + struct atlantis_clk_gate_shared *gate =3D + hw_to_atlantis_clk_gate_shared(hw); + u32 reg; + + scoped_guard(spinlock_irqsave, gate->config.refcount_lock) + { + if (WARN_ON(*gate->config.share_count =3D=3D 0)) + return; + if (--(*gate->config.share_count) > 0) + return; + + regmap_read(gate->common.regmap, gate->config.reg_offset, ®); + reg &=3D ~gate->config.enable; + regmap_write(gate->common.regmap, gate->config.reg_offset, reg); + } +} + +static int atlantis_clk_gate_shared_is_enabled(struct clk_hw *hw) +{ + struct atlantis_clk_gate_shared *gate =3D + hw_to_atlantis_clk_gate_shared(hw); + u32 reg; + + regmap_read(gate->common.regmap, gate->config.reg_offset, ®); + + return !!(reg & gate->config.enable); +} + +static void atlantis_clk_gate_shared_disable_unused(struct clk_hw *hw) +{ + struct atlantis_clk_gate_shared *gate =3D + hw_to_atlantis_clk_gate_shared(hw); + + u32 reg; + + scoped_guard(spinlock_irqsave, gate->config.refcount_lock) + { + if (*gate->config.share_count =3D=3D 0) { + regmap_read(gate->common.regmap, + gate->config.reg_offset, ®); + reg &=3D ~gate->config.enable; + regmap_write(gate->common.regmap, + gate->config.reg_offset, reg); + } + } +} + +static const struct clk_ops atlantis_clk_gate_shared_ops =3D { + .enable =3D atlantis_clk_gate_shared_enable, + .disable =3D atlantis_clk_gate_shared_disable, + .disable_unused =3D atlantis_clk_gate_shared_disable_unused, + .is_enabled =3D atlantis_clk_gate_shared_is_enabled, +}; + +#define ATLANTIS_PLL_CONFIG(_reg_offset, _en_reg_offset, _cg_reg_offset, \ + _cg_reg_enable) \ + { \ + .reg_offset =3D (_reg_offset), \ + .en_reg_offset =3D (_en_reg_offset), \ + .cg_reg_offset =3D (_cg_reg_offset), \ + .cg_reg_enable =3D (_cg_reg_enable), \ + } + +#define ATLANTIS_PLL_DEFINE(_clkid, _name, _parent, _reg_offset, = \ + _en_reg_offset, _cg_reg_offset, _cg_reg_enable, \ + _flags) \ + static struct atlantis_clk_pll _name =3D { \ + .config =3D ATLANTIS_PLL_CONFIG(_reg_offset, _en_reg_offset, \ + _cg_reg_offset, _cg_reg_enable), \ + .common =3D { .clkid =3D _clkid, \ + .hw.init =3D CLK_HW_INIT_PARENTS_DATA( \ + #_name, _parent, &atlantis_clk_pll_ops, \ + _flags) }, \ + } +#define ATLANTIS_MUX_CONFIG(_shift, _width, _reg_offset) = \ + { \ + .shift =3D _shift, .width =3D _width, .reg_offset =3D _reg_offset \ + } + +#define ATLANTIS_MUX_DEFINE(_clkid, _name, _parents, _reg_offset, _shift, = \ + _width, _flags) \ + static struct atlantis_clk_mux _name =3D { \ + .config =3D ATLANTIS_MUX_CONFIG(_shift, _width, _reg_offset), \ + .common =3D { .clkid =3D _clkid, \ + .hw.init =3D CLK_HW_INIT_PARENTS_DATA( \ + #_name, _parents, &atlantis_clk_mux_ops, \ + _flags) } \ + } + +#define ATLANTIS_DIVIDER_CONFIG(_shift, _width, _flags, _reg_offset) \ + { \ + .shift =3D _shift, .width =3D _width, .flags =3D _flags, \ + .reg_offset =3D _reg_offset \ + } + +#define ATLANTIS_DIVIDER_DEFINE(_clkid, _name, _parent, _reg_offset, _shif= t, \ + _width, _divflags, _flags) \ + static struct atlantis_clk_divider _name =3D { \ + .config =3D ATLANTIS_DIVIDER_CONFIG(_shift, _width, _divflags, \ + _reg_offset), \ + .common =3D { .clkid =3D _clkid, \ + .hw.init =3D CLK_HW_INIT_HW( \ + #_name, &_parent.common.hw, \ + &atlantis_clk_divider_ops, _flags) } \ + } +#define ATLANTIS_GATE_CONFIG(_enable, _reg_offset) \ + { \ + .enable =3D _enable, .reg_offset =3D _reg_offset \ + } + +#define ATLANTIS_GATE_DEFINE(_clkid, _name, _parent, _reg_offset, _enable,= \ + _flags) \ + static struct atlantis_clk_gate _name =3D { \ + .config =3D ATLANTIS_GATE_CONFIG(_enable, _reg_offset), \ + .common =3D { .clkid =3D _clkid, \ + .hw.init =3D CLK_HW_INIT_HW( \ + #_name, &_parent.common.hw, \ + &atlantis_clk_gate_ops, _flags) } \ + } +#define ATLANTIS_GATE_SHARED_CONFIG(_reg_offset, _enable, _share_count) = \ + { \ + .reg_offset =3D _reg_offset, .enable =3D _enable, \ + .share_count =3D _share_count, .refcount_lock =3D &refcount_lock \ + } +#define ATLANTIS_GATE_SHARED_DEFINE(_clkid, _name, _parent, _reg_offset, = \ + _enable, _share_count, _flags) \ + static struct atlantis_clk_gate_shared _name =3D { \ + .config =3D ATLANTIS_GATE_SHARED_CONFIG(_reg_offset, _enable, \ + _share_count), \ + .common =3D { .clkid =3D _clkid, \ + .hw.init =3D CLK_HW_INIT_HW( \ + #_name, &_parent.common.hw, \ + &atlantis_clk_gate_shared_ops, _flags) } \ + } +#define ATLANTIS_CLK_FIXED_FACTOR_DEFINE(_clkid, _name, _parent, _mult, _d= iv, \ + _flags) \ + static struct atlantis_clk_fixed_factor _name =3D { \ + .config =3D { .mult =3D _mult, .div =3D _div }, \ + .common =3D { .clkid =3D _clkid, \ + .hw.init =3D CLK_HW_INIT_HW( \ + #_name, &_parent.common.hw, \ + &atlantis_clk_fixed_factor_ops, _flags) } \ + } + +static DEFINE_SPINLOCK(refcount_lock); /* Lock for refcount value accesses= */ + +static const struct regmap_config atlantis_prcm_regmap_config =3D { + .reg_bits =3D 32, + .reg_stride =3D 4, + .val_bits =3D 32, + .max_register =3D 0xFFFC, + .cache_type =3D REGCACHE_NONE, +}; + +struct atlantis_prcm_data { + struct clk_hw **hws; + size_t num; + const char *reset_name; +}; + +static const struct clk_parent_data osc_24m_clk[] =3D { + { .index =3D 0 }, +}; + +ATLANTIS_PLL_DEFINE(CLK_RCPU_PLL, rcpu_pll_clk, osc_24m_clk, RCPU_PLL_CFG_= REG, + PLL_RCPU_EN_REG, BUS_CG_REG, 0, /* No Gate Clk at Output */ + CLK_GET_RATE_NOCACHE | CLK_IS_CRITICAL); + +static const struct clk_parent_data rcpu_root_parents[] =3D { + { .index =3D 0 }, + { .hw =3D &rcpu_pll_clk.common.hw }, +}; + +ATLANTIS_MUX_DEFINE(CLK_RCPU_ROOT, rcpu_root_mux, rcpu_root_parents, + RCPU_DIV_CFG_REG, 0, 1, CLK_SET_RATE_NO_REPARENT); + +ATLANTIS_DIVIDER_DEFINE(CLK_RCPU_DIV2, rcpu_div2_clk, rcpu_root_mux, + RCPU_DIV_CFG_REG, 2, 4, 0, 0); +ATLANTIS_DIVIDER_DEFINE(CLK_RCPU_DIV4, rcpu_div4_clk, rcpu_root_mux, + RCPU_DIV_CFG_REG, 7, 4, 0, 0); +ATLANTIS_DIVIDER_DEFINE(CLK_RCPU_RTC, rcpu_rtc_clk, rcpu_div4_clk, + RCPU_DIV_CFG_REG, 12, 6, 0, 0); + +ATLANTIS_GATE_DEFINE(CLK_SMNDMA0_ACLK, smndma0_aclk, rcpu_div2_clk, + RCPU_BLK_CG_REG, BIT(0), 0); +ATLANTIS_GATE_DEFINE(CLK_SMNDMA1_ACLK, smndma1_aclk, rcpu_div2_clk, + RCPU_BLK_CG_REG, BIT(1), 0); +ATLANTIS_GATE_DEFINE(CLK_WDT0_PCLK, wdt0_pclk, rcpu_div4_clk, RCPU_BLK_CG_= REG, + BIT(2), 0); +ATLANTIS_GATE_DEFINE(CLK_WDT1_PCLK, wdt1_pclk, rcpu_div4_clk, RCPU_BLK_CG_= REG, + BIT(3), 0); +ATLANTIS_GATE_DEFINE(CLK_TIMER_PCLK, timer_pclk, rcpu_div4_clk, RCPU_BLK_C= G_REG, + BIT(4), 0); +ATLANTIS_GATE_DEFINE(CLK_PVTC_PCLK, pvtc_pclk, rcpu_div4_clk, RCPU_BLK_CG_= REG, + BIT(12), 0); +ATLANTIS_GATE_DEFINE(CLK_PMU_PCLK, pmu_pclk, rcpu_div4_clk, RCPU_BLK_CG_RE= G, + BIT(13), 0); +ATLANTIS_GATE_DEFINE(CLK_MAILBOX_HCLK, mb_hclk, rcpu_div2_clk, RCPU_BLK_CG= _REG, + BIT(14), 0); +ATLANTIS_GATE_DEFINE(CLK_SEC_SPACC_HCLK, sec_spacc_hclk, rcpu_div2_clk, + RCPU_BLK_CG_REG, BIT(26), 0); +ATLANTIS_GATE_DEFINE(CLK_SEC_OTP_HCLK, sec_otp_hclk, rcpu_div2_clk, + RCPU_BLK_CG_REG, BIT(28), 0); +ATLANTIS_GATE_DEFINE(CLK_TRNG_PCLK, trng_pclk, rcpu_div4_clk, RCPU_BLK_CG_= REG, + BIT(29), 0); +ATLANTIS_GATE_DEFINE(CLK_SEC_CRC_HCLK, sec_crc_hclk, rcpu_div2_clk, + RCPU_BLK_CG_REG, BIT(30), 0); + +ATLANTIS_CLK_FIXED_FACTOR_DEFINE(CLK_SMN_HCLK, rcpu_smn_hclk, rcpu_div2_cl= k, 1, + 1, 0); +ATLANTIS_CLK_FIXED_FACTOR_DEFINE(CLK_AHB0_HCLK, rcpu_ahb0_hclk, rcpu_div2_= clk, + 1, 1, 0); + +ATLANTIS_CLK_FIXED_FACTOR_DEFINE(CLK_SMN_PCLK, rcpu_smn_pclk, rcpu_div4_cl= k, 1, + 1, 0); + +ATLANTIS_CLK_FIXED_FACTOR_DEFINE(CLK_SMN_CLK, rcpu_smn_clk, rcpu_root_mux,= 1, 1, + 0); +ATLANTIS_CLK_FIXED_FACTOR_DEFINE(CLK_SCRATCHPAD_CLK, rcpu_scratchpad_aclk, + rcpu_root_mux, 1, 1, 0); +ATLANTIS_CLK_FIXED_FACTOR_DEFINE(CLK_RCPU_CORE_CLK, rcpu_core_clk, + rcpu_root_mux, 1, 1, 0); +ATLANTIS_CLK_FIXED_FACTOR_DEFINE(CLK_RCPU_ROM_CLK, rcpu_rom_aclk, rcpu_roo= t_mux, + 1, 1, 0); + +static struct atlantis_clk_fixed_factor + otp_load_clk =3D { .config =3D { .mult =3D 1, .div =3D 1 }, + .common =3D { + .clkid =3D CLK_OTP_LOAD_CLK, + .hw.init =3D CLK_HW_INIT_PARENTS_DATA( + "otp_load_clk", osc_24m_clk, + &atlantis_clk_fixed_factor_ops, + CLK_SET_RATE_NO_REPARENT), + } }; + +ATLANTIS_PLL_DEFINE(CLK_NOC_PLL, nocc_pll_clk, osc_24m_clk, + RCPU_NOCC_PLL_CFG_REG, PLL_NOCC_EN_REG, BUS_CG_REG, BIT(0), + CLK_GET_RATE_NOCACHE | CLK_IS_CRITICAL); + +static const struct clk_parent_data nocc_mux_parents[] =3D { + { .index =3D 0 }, + { .hw =3D &nocc_pll_clk.common.hw }, +}; + +ATLANTIS_MUX_DEFINE(CLK_NOCC_CLK, nocc_clk_mux, nocc_mux_parents, + RCPU_NOCC_CLK_CFG_REG, 0, 1, CLK_SET_RATE_NO_REPARENT); + +ATLANTIS_DIVIDER_DEFINE(CLK_NOCC_DIV2, nocc_div2_clk, nocc_clk_mux, + RCPU_NOCC_CLK_CFG_REG, 1, 4, 0, 0); +ATLANTIS_DIVIDER_DEFINE(CLK_NOCC_DIV4, nocc_div4_clk, nocc_clk_mux, + RCPU_NOCC_CLK_CFG_REG, 5, 4, 0, 0); +ATLANTIS_DIVIDER_DEFINE(CLK_NOCC_RTC, nocc_rtc_clk, nocc_div4_clk, + RCPU_NOCC_CLK_CFG_REG, 9, 6, 0, 0); +ATLANTIS_DIVIDER_DEFINE(CLK_NOCC_CAN, nocc_can_div, nocc_clk_mux, + RCPU_NOCC_CLK_CFG_REG, 15, 4, 0, 0); + +static unsigned int refcnt_qspi; +ATLANTIS_GATE_SHARED_DEFINE(CLK_QSPI_SCLK, qspi_sclk, nocc_clk_mux, + LSIO_BLK_CG_REG, BIT(0), &refcnt_qspi, 0); +ATLANTIS_GATE_SHARED_DEFINE(CLK_QSPI_HCLK, qspi_hclk, nocc_div2_clk, + LSIO_BLK_CG_REG, BIT(0), &refcnt_qspi, 0); +ATLANTIS_GATE_DEFINE(CLK_I2C0_PCLK, i2c0_pclk, nocc_div4_clk, LSIO_BLK_CG_= REG, + BIT(1), 0); +ATLANTIS_GATE_DEFINE(CLK_I2C1_PCLK, i2c1_pclk, nocc_div4_clk, LSIO_BLK_CG_= REG, + BIT(2), 0); +ATLANTIS_GATE_DEFINE(CLK_I2C2_PCLK, i2c2_pclk, nocc_div4_clk, LSIO_BLK_CG_= REG, + BIT(3), 0); +ATLANTIS_GATE_DEFINE(CLK_I2C3_PCLK, i2c3_pclk, nocc_div4_clk, LSIO_BLK_CG_= REG, + BIT(4), 0); +ATLANTIS_GATE_DEFINE(CLK_I2C4_PCLK, i2c4_pclk, nocc_div4_clk, LSIO_BLK_CG_= REG, + BIT(5), 0); + +ATLANTIS_GATE_DEFINE(CLK_UART0_PCLK, uart0_pclk, nocc_div4_clk, LSIO_BLK_C= G_REG, + BIT(6), 0); +ATLANTIS_GATE_DEFINE(CLK_UART1_PCLK, uart1_pclk, nocc_div4_clk, LSIO_BLK_C= G_REG, + BIT(7), 0); +ATLANTIS_GATE_DEFINE(CLK_UART2_PCLK, uart2_pclk, nocc_div4_clk, LSIO_BLK_C= G_REG, + BIT(8), 0); +ATLANTIS_GATE_DEFINE(CLK_UART3_PCLK, uart3_pclk, nocc_div4_clk, LSIO_BLK_C= G_REG, + BIT(9), 0); +ATLANTIS_GATE_DEFINE(CLK_UART4_PCLK, uart4_pclk, nocc_div4_clk, LSIO_BLK_C= G_REG, + BIT(10), 0); +ATLANTIS_GATE_DEFINE(CLK_SPI0_PCLK, spi0_pclk, nocc_div4_clk, LSIO_BLK_CG_= REG, + BIT(11), 0); +ATLANTIS_GATE_DEFINE(CLK_SPI1_PCLK, spi1_pclk, nocc_div4_clk, LSIO_BLK_CG_= REG, + BIT(12), 0); +ATLANTIS_GATE_DEFINE(CLK_SPI2_PCLK, spi2_pclk, nocc_div4_clk, LSIO_BLK_CG_= REG, + BIT(13), 0); +ATLANTIS_GATE_DEFINE(CLK_SPI3_PCLK, spi3_pclk, nocc_div4_clk, LSIO_BLK_CG_= REG, + BIT(14), 0); +ATLANTIS_GATE_DEFINE(CLK_GPIO_PCLK, gpio_pclk, nocc_div4_clk, LSIO_BLK_CG_= REG, + BIT(15), 0); + +static unsigned int refcnt_can0; +ATLANTIS_GATE_SHARED_DEFINE(CLK_CAN0_HCLK, can0_hclk, nocc_div2_clk, + LSIO_BLK_CG_REG, BIT(17), &refcnt_can0, 0); +ATLANTIS_GATE_SHARED_DEFINE(CLK_CAN0_CLK, can0_clk, nocc_can_div, + LSIO_BLK_CG_REG, BIT(17), &refcnt_can0, 0); + +static unsigned int refcnt_can1; +ATLANTIS_GATE_SHARED_DEFINE(CLK_CAN1_HCLK, can1_hclk, nocc_div2_clk, + LSIO_BLK_CG_REG, BIT(18), &refcnt_can1, 0); +ATLANTIS_GATE_SHARED_DEFINE(CLK_CAN1_CLK, can1_clk, nocc_can_div, + LSIO_BLK_CG_REG, BIT(18), &refcnt_can1, 0); + +ATLANTIS_CLK_FIXED_FACTOR_DEFINE(CLK_CAN0_TIMER_CLK, can0_timer_clk, + nocc_rtc_clk, 1, 1, 0); +ATLANTIS_CLK_FIXED_FACTOR_DEFINE(CLK_CAN1_TIMER_CLK, can1_timer_clk, + nocc_rtc_clk, 1, 1, 0); + +static struct clk_hw *atlantis_rcpu_clks[] =3D { + [CLK_RCPU_PLL] =3D &rcpu_pll_clk.common.hw, + [CLK_RCPU_ROOT] =3D &rcpu_root_mux.common.hw, + [CLK_RCPU_DIV2] =3D &rcpu_div2_clk.common.hw, + [CLK_RCPU_DIV4] =3D &rcpu_div4_clk.common.hw, + [CLK_RCPU_RTC] =3D &rcpu_rtc_clk.common.hw, + [CLK_SMNDMA0_ACLK] =3D &smndma0_aclk.common.hw, + [CLK_SMNDMA1_ACLK] =3D &smndma1_aclk.common.hw, + [CLK_WDT0_PCLK] =3D &wdt0_pclk.common.hw, + [CLK_WDT1_PCLK] =3D &wdt1_pclk.common.hw, + [CLK_TIMER_PCLK] =3D &timer_pclk.common.hw, + [CLK_PVTC_PCLK] =3D &pvtc_pclk.common.hw, + [CLK_PMU_PCLK] =3D &pmu_pclk.common.hw, + [CLK_MAILBOX_HCLK] =3D &mb_hclk.common.hw, + [CLK_SEC_SPACC_HCLK] =3D &sec_spacc_hclk.common.hw, + [CLK_SEC_OTP_HCLK] =3D &sec_otp_hclk.common.hw, + [CLK_TRNG_PCLK] =3D &trng_pclk.common.hw, + [CLK_SEC_CRC_HCLK] =3D &sec_crc_hclk.common.hw, + [CLK_SMN_HCLK] =3D &rcpu_smn_hclk.common.hw, + [CLK_AHB0_HCLK] =3D &rcpu_ahb0_hclk.common.hw, + [CLK_SMN_PCLK] =3D &rcpu_smn_pclk.common.hw, + [CLK_SMN_CLK] =3D &rcpu_smn_clk.common.hw, + [CLK_SCRATCHPAD_CLK] =3D &rcpu_scratchpad_aclk.common.hw, + [CLK_RCPU_CORE_CLK] =3D &rcpu_core_clk.common.hw, + [CLK_RCPU_ROM_CLK] =3D &rcpu_rom_aclk.common.hw, + [CLK_OTP_LOAD_CLK] =3D &otp_load_clk.common.hw, + [CLK_NOC_PLL] =3D &nocc_pll_clk.common.hw, + [CLK_NOCC_CLK] =3D &nocc_clk_mux.common.hw, + [CLK_NOCC_DIV2] =3D &nocc_div2_clk.common.hw, + [CLK_NOCC_DIV4] =3D &nocc_div4_clk.common.hw, + [CLK_NOCC_RTC] =3D &nocc_rtc_clk.common.hw, + [CLK_NOCC_CAN] =3D &nocc_can_div.common.hw, + [CLK_QSPI_SCLK] =3D &qspi_sclk.common.hw, + [CLK_QSPI_HCLK] =3D &qspi_hclk.common.hw, + [CLK_I2C0_PCLK] =3D &i2c0_pclk.common.hw, + [CLK_I2C1_PCLK] =3D &i2c1_pclk.common.hw, + [CLK_I2C2_PCLK] =3D &i2c2_pclk.common.hw, + [CLK_I2C3_PCLK] =3D &i2c3_pclk.common.hw, + [CLK_I2C4_PCLK] =3D &i2c4_pclk.common.hw, + [CLK_UART0_PCLK] =3D &uart0_pclk.common.hw, + [CLK_UART1_PCLK] =3D &uart1_pclk.common.hw, + [CLK_UART2_PCLK] =3D &uart2_pclk.common.hw, + [CLK_UART3_PCLK] =3D &uart3_pclk.common.hw, + [CLK_UART4_PCLK] =3D &uart4_pclk.common.hw, + [CLK_SPI0_PCLK] =3D &spi0_pclk.common.hw, + [CLK_SPI1_PCLK] =3D &spi1_pclk.common.hw, + [CLK_SPI2_PCLK] =3D &spi2_pclk.common.hw, + [CLK_SPI3_PCLK] =3D &spi3_pclk.common.hw, + [CLK_GPIO_PCLK] =3D &gpio_pclk.common.hw, + [CLK_CAN0_HCLK] =3D &can0_hclk.common.hw, + [CLK_CAN0_CLK] =3D &can0_clk.common.hw, + [CLK_CAN1_HCLK] =3D &can1_hclk.common.hw, + [CLK_CAN1_CLK] =3D &can1_clk.common.hw, + [CLK_CAN0_TIMER_CLK] =3D &can0_timer_clk.common.hw, + [CLK_CAN1_TIMER_CLK] =3D &can1_timer_clk.common.hw, +}; + +static const struct atlantis_prcm_data atlantis_prcm_rcpu_data =3D { + .hws =3D atlantis_rcpu_clks, + .num =3D ARRAY_SIZE(atlantis_rcpu_clks), + .reset_name =3D "rcpu-reset" +}; + +static int atlantis_prcm_clocks_register(struct device *dev, + struct regmap *regmap, + const struct atlantis_prcm_data *data) +{ + struct clk_hw_onecell_data *clk_data; + int i, ret; + size_t num_clks =3D data->num; + + clk_data =3D devm_kzalloc(dev, struct_size(clk_data, hws, data->num), + GFP_KERNEL); + if (!clk_data) + return -ENOMEM; + + for (i =3D 0; i < data->num; i++) { + struct clk_hw *hw =3D data->hws[i]; + struct atlantis_clk_common *common =3D + hw_to_atlantis_clk_common(hw); + common->regmap =3D regmap; + + ret =3D devm_clk_hw_register(dev, hw); + + if (ret) + return ret; + + clk_data->hws[common->clkid] =3D hw; + } + + clk_data->num =3D num_clks; + + ret =3D devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data); + + return ret; +} + +static int atlantis_prcm_probe(struct platform_device *pdev) +{ + const struct atlantis_prcm_data *data; + struct auxiliary_device *reset_adev; + struct regmap *regmap; + void __iomem *base; + struct device *dev =3D &pdev->dev; + int ret; + + base =3D devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(base)) + return dev_err_probe(dev, PTR_ERR(base), + "Failed to map registers\n"); + + regmap =3D devm_regmap_init_mmio(dev, base, &atlantis_prcm_regmap_config); + if (IS_ERR(regmap)) + return dev_err_probe(dev, PTR_ERR(regmap), + "Failed to init regmap\n"); + + data =3D of_device_get_match_data(dev); + + ret =3D atlantis_prcm_clocks_register(dev, regmap, data); + if (ret) + return dev_err_probe(dev, ret, "failed to register clocks\n"); + + reset_adev =3D devm_auxiliary_device_create(dev, data->reset_name, NULL); + if (!reset_adev) + return dev_err_probe(dev, -ENODEV, "failed to register resets\n"); + + return 0; +} + +static const struct of_device_id atlantis_prcm_of_match[] =3D { + { + .compatible =3D "tenstorrent,atlantis-prcm-rcpu", + .data =3D &atlantis_prcm_rcpu_data, + }, + {} + +}; +MODULE_DEVICE_TABLE(of, atlantis_prcm_of_match); + +static struct platform_driver atlantis_prcm_driver =3D { + .probe =3D atlantis_prcm_probe, + .driver =3D { + .name =3D "atlantis-prcm", + .of_match_table =3D atlantis_prcm_of_match, + }, +}; +module_platform_driver(atlantis_prcm_driver); + +MODULE_DESCRIPTION("Tenstorrent Atlantis PRCM Clock Controller Driver"); +MODULE_AUTHOR("Anirudh Srinivasan "); +MODULE_LICENSE("GPL"); --=20 2.43.0