From nobody Fri Dec 19 12:31:50 2025 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (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 52C265244 for ; Sat, 27 Apr 2024 00:10:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714176658; cv=none; b=SX3pEHbxD9VTZ0d5ao6MjycNLd93qxGvsdymJ6Jn3U53cmAZ6DynWg1Ofg/J3ugFmPL1Py82pdqBMdV+9MnHoddBmeHXpahNPBME6l4uwrv94R85xIxpdakw7sUKcwnVzjboxL8uovfAxKyoYp6YcBnRoeAAZ8+IW6BeYAo8cYg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714176658; c=relaxed/simple; bh=sMOxHU5KMFZs4iNqEZa826xHNb+O2YxTHVtzCtgnVzE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tAPdjrs9G6wRhPxpZfQdzAr+xNUqoipJHQnM+IQRnziAfEL3iRNseRFvX4A0YduXb8rt832WLv47vGexwdb9q4yHBf9Rx/oaZhVQm7orOlU2wPgKdBpPKeLnEVuJzH3bs7a3YtNpu/EuYgKZkkdDH3Ybwh286LC/IQaENXbNkMc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=tenstorrent.com; spf=pass smtp.mailfrom=tenstorrent.com; dkim=pass (2048-bit key) header.d=tenstorrent.com header.i=@tenstorrent.com header.b=P9yapMlU; arc=none smtp.client-ip=209.85.210.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=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="P9yapMlU" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-6ecff9df447so2725273b3a.1 for ; Fri, 26 Apr 2024 17:10:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tenstorrent.com; s=google; t=1714176656; x=1714781456; 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=hrlLXZWpuiMESLDTJ+xPjDizCDXOjxRIPese3PIiRKI=; b=P9yapMlU/vmmA8qrU/kXs2pRtDicT8td5khYvzL6snQRqrn11Tgv6Fs1ZHGcd83IUZ XZbxVxb+CC0TS+C7wVmC5NRULsjfS/q9iPNAlyQQZJaAVvGxNHSPJPfdHgV95F5ut/Q8 jJO8J71EUL1nyNwHLI1IT2rVErS6zXAlrUk8Br71a7evWzs95LG1988/kTkULzmcVp0x zgRGisUmtuMQoHEWAnqd89kStOUXeejg83le+qYEUgHHqZYOMs4vt5cyqsgNyj3OZSLF 2hFczK1NCYRcNCE9eSk0xanENlwjsoKikXN+XBCx1Q2NZHY0jD77N3bA1zWW8V1w3i6V 6dMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714176656; x=1714781456; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hrlLXZWpuiMESLDTJ+xPjDizCDXOjxRIPese3PIiRKI=; b=NMGMuApFXmzNWivscWXUNJo4MPAkmqEGCSU0limmTF6huM4xO7mo59YZ0dWWU2c5JD iKAOUBeFL2V/vvcy2W72pmBBhQf4O9E3aBhDg2EH+5g56eK09Q1kPw3HCcDbASBCwwY5 CiomL5GD54oCIb+mAUPzLF0gW3O3SOu3VYnQsNXM5aKGIJ9Ku2z9ep6h9xH47kUJh+Pk hur0S/hpzJzmvFboHKvxiiyzpk3etZnom6O/RPjAwskcVvN8jGQECeXcZt/ZXd1Qj04o 9O9HByPdIkKCRWP/vpZjmnlUW22u/EGyzy2X1lYcFagsddZBdUtVuNna+b3+QUgi5GRH u0Zg== X-Forwarded-Encrypted: i=1; AJvYcCVNsBQUfhmzkH9emA09RAkE4c8r+coop5UgJDXJl8oje8F8QclO1GVV4T697WS7XkKyr2ocrBxyJY1Ngv5OyPFbq5XomjS7uB3IJafp X-Gm-Message-State: AOJu0YxgHlNuL/8Hrkwsm+hnoV5v0hwGMAQWi9ZgrTOpsLkDA30bXQ9t a8iz7gtmUT9DzD5IZvYDNbGIPMmyH3tuKHXwYBWDkkwyC4/Xd6evZcLeQ4aTcOY= X-Google-Smtp-Source: AGHT+IG4wumPhODLqSYj/1OQ3+tavjARweTZgxxYtKaCTo8UfjzaeyAZVKJnT0PLnRQ0o9FND8xXBQ== X-Received: by 2002:a05:6a20:5505:b0:1a3:bfce:ec9e with SMTP id ko5-20020a056a20550500b001a3bfceec9emr4300497pzb.18.1714176656588; Fri, 26 Apr 2024 17:10:56 -0700 (PDT) Received: from [127.0.1.1] ([2601:1c2:1802:170:3569:7ce4:94b8:1691]) by smtp.gmail.com with ESMTPSA id w1-20020a6556c1000000b005f3d54c0a57sm6061883pgs.49.2024.04.26.17.10.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 17:10:56 -0700 (PDT) From: Drew Fustini Date: Fri, 26 Apr 2024 17:10:34 -0700 Subject: [PATCH RFC v2 1/4] dt-bindings: clock: Document T-Head TH1520 AP_SUBSYS controller 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: <20240426-th1520-clk-v2-v2-1-96b829e6fcee@tenstorrent.com> References: <20240426-th1520-clk-v2-v2-0-96b829e6fcee@tenstorrent.com> In-Reply-To: <20240426-th1520-clk-v2-v2-0-96b829e6fcee@tenstorrent.com> To: Jisheng Zhang , Guo Ren , Fu Wei , Yangtao Li , Thomas Bonnefille , Emil Renner Berthing , Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Drew Fustini , Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: linux-riscv@lists.infradead.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1714176654; l=5695; i=dfustini@tenstorrent.com; s=20230430; h=from:subject:message-id; bh=sMOxHU5KMFZs4iNqEZa826xHNb+O2YxTHVtzCtgnVzE=; b=yvQQ3If1wAxIon7Fk0UROAd49XxIxfJCQ1waX2ubKqW+XZg2OJGEHSUO0CK7CZVaWTYdk77zD KqBVDOt7pUhDdW/UHKYTS2TimfCRaDsO5xworU7nT8iGulWCpyWS+ze X-Developer-Key: i=dfustini@tenstorrent.com; a=ed25519; pk=p3GKE9XFmjhwAayAHG4U108yag7V8xQVd4zJLdW0g7g= Document bindings for the T-Head TH1520 AP sub-system clock controller. Link: https://openbeagle.org/beaglev-ahead/beaglev-ahead/-/blob/main/docs/T= H1520%20System%20User%20Manual.pdf Co-developed-by: Yangtao Li Signed-off-by: Yangtao Li Signed-off-by: Drew Fustini Tested-by: Thomas Bonnefille --- .../bindings/clock/thead,th1520-clk-ap.yaml | 65 +++++++++++++++ MAINTAINERS | 2 + include/dt-bindings/clock/thead,th1520-clk-ap.h | 96 ++++++++++++++++++= ++++ 3 files changed, 163 insertions(+) diff --git a/Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.ya= ml b/Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml new file mode 100644 index 000000000000..611edc90f7b3 --- /dev/null +++ b/Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml @@ -0,0 +1,65 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/thead,th1520-clk-ap.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: T-HEAD TH1520 AP sub-system clock controller + +description: | + The T-HEAD TH1520 AP sub-system clock controller configures the + CPU, DPU, GMAC and TEE PLLs. + + SoC reference manual + https://openbeagle.org/beaglev-ahead/beaglev-ahead/-/blob/main/docs/TH15= 20%20System%20User%20Manual.pdf + +maintainers: + - Jisheng Zhang + - Wei Fu + - Drew Fustini + +properties: + compatible: + const: thead,th1520-clk-ap + + reg: + maxItems: 1 + + clocks: + items: + - description: main oscillator (24MHz) + + clock-names: + items: + - const: osc + + "#clock-cells": + const: 1 + description: + See for valid indices. + +required: + - compatible + - reg + - clocks + - clock-names + - "#clock-cells" + +additionalProperties: false + +examples: + - | + #include + soc { + + #address-cells =3D <2>; + #size-cells =3D <2>; + + clk: clock-controller@ffef010000 { + compatible =3D "thead,th1520-clk-ap"; + reg =3D <0xff 0xef010000 0x0 0x1000>; + clocks =3D <&osc>; + clock-names =3D "osc"; + #clock-cells =3D <1>; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index ebf03f5f0619..51d550cb1329 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19023,7 +19023,9 @@ M: Guo Ren M: Fu Wei L: linux-riscv@lists.infradead.org S: Maintained +F: Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml F: arch/riscv/boot/dts/thead/ +F: include/dt-bindings/clock/thead,th1520-clk-ap.h =20 RNBD BLOCK DRIVERS M: Md. Haris Iqbal diff --git a/include/dt-bindings/clock/thead,th1520-clk-ap.h b/include/dt-b= indings/clock/thead,th1520-clk-ap.h new file mode 100644 index 000000000000..d0d1ab1e672a --- /dev/null +++ b/include/dt-bindings/clock/thead,th1520-clk-ap.h @@ -0,0 +1,96 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +/* + * Copyright (C) 2023 Vivo Communication Technology Co. Ltd. + * Authors: Yangtao Li + */ + +#ifndef _DT_BINDINGS_CLK_TH1520_H_ +#define _DT_BINDINGS_CLK_TH1520_H_ + +#define CLK_CPU_PLL0 0 +#define CLK_CPU_PLL1 1 +#define CLK_GMAC_PLL 2 +#define CLK_VIDEO_PLL 3 +#define CLK_DPU0_PLL 4 +#define CLK_DPU1_PLL 5 +#define CLK_TEE_PLL 6 +#define CLK_C910_I0 7 +#define CLK_C910 8 +#define CLK_BROM 9 +#define CLK_BMU 10 +#define CLK_AHB2_CPUSYS_HCLK 11 +#define CLK_APB3_CPUSYS_PCLK 12 +#define CLK_AXI4_CPUSYS2_ACLK 13 +#define CLK_AON2CPU_A2X 14 +#define CLK_X2X_CPUSYS 15 +#define CLK_AXI_ACLK 16 +#define CLK_CPU2AON_X2H 17 +#define CLK_PERI_AHB_HCLK 18 +#define CLK_CPU2PERI_X2H 19 +#define CLK_PERI_APB_PCLK 20 +#define CLK_PERI2APB_PCLK 21 +#define CLK_PERI_APB1_HCLK 22 +#define CLK_PERI_APB2_HCLK 23 +#define CLK_PERI_APB3_HCLK 24 +#define CLK_PERI_APB4_HCLK 25 +#define CLK_OSC12M 26 +#define CLK_OUT1 27 +#define CLK_OUT2 28 +#define CLK_OUT3 29 +#define CLK_OUT4 30 +#define CLK_APB_PCLK 31 +#define CLK_NPU 32 +#define CLK_NPU_AXI 33 +#define CLK_VI 34 +#define CLK_VI_AHB 35 +#define CLK_VO_AXI 36 +#define CLK_VP_APB 37 +#define CLK_VP_AXI 38 +#define CLK_CPU2VP 39 +#define CLK_VENC 40 +#define CLK_DPU0 41 +#define CLK_DPU1 42 +#define CLK_EMMC_SDIO 43 +#define CLK_GMAC1 44 +#define CLK_PADCTRL1 45 +#define CLK_DSMART 46 +#define CLK_PADCTRL0 47 +#define CLK_GMAC_AXI 48 +#define CLK_GPIO3 49 +#define CLK_GMAC0 50 +#define CLK_PWM 51 +#define CLK_QSPI0 52 +#define CLK_QSPI1 53 +#define CLK_SPI 54 +#define CLK_UART0_PCLK 55 +#define CLK_UART1_PCLK 56 +#define CLK_UART2_PCLK 57 +#define CLK_UART3_PCLK 58 +#define CLK_UART4_PCLK 59 +#define CLK_UART5_PCLK 60 +#define CLK_GPIO0 61 +#define CLK_GPIO1 62 +#define CLK_GPIO2 63 +#define CLK_I2C0 64 +#define CLK_I2C1 65 +#define CLK_I2C2 66 +#define CLK_I2C3 67 +#define CLK_I2C4 68 +#define CLK_I2C5 69 +#define CLK_SPINLOCK 70 +#define CLK_DMA 71 +#define CLK_MBOX0 72 +#define CLK_MBOX1 73 +#define CLK_MBOX2 74 +#define CLK_MBOX3 75 +#define CLK_WDT0 76 +#define CLK_WDT1 77 +#define CLK_TIMER0 78 +#define CLK_TIMER1 79 +#define CLK_SRAM0 80 +#define CLK_SRAM1 81 +#define CLK_SRAM2 82 +#define CLK_SRAM3 83 +#define CLK_PLL_GMAC_100M 84 +#define CLK_UART_SCLK 85 +#endif --=20 2.34.1 From nobody Fri Dec 19 12:31:50 2025 Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (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 9D277611B for ; Sat, 27 Apr 2024 00:10:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714176661; cv=none; b=ndYpqjweY92Jwp8PX+mwQivAM76wVa7/CYGC7Od+ofLajzoc4Ii9JfeiT0Ht/u+jIObEwPxSRPy1De9Irj0+wBeka6w0XkEyhLEqi5Z+x62jgZwybIkhiY1hY/fYFSPw80BOMvwYq16CcwFLkXVR3+74tFBG1LCtM6aHSii37QU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714176661; c=relaxed/simple; bh=FxwfDsXMNi6nOG8OLcKaN3n7jcJsSjXmtP4iQAH+beU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DPuoZBlnqiv80/pabJLG/OqgTe9drLsZn4gdWBr/L8jwJlcLf8kNIMHJKtGsM5t34J8GfJSJ1E7zNWwOnYVUSEE8ikgjU6WnhXEwLAqvqaJ73e8EUnZdMR0LJpQoeDFUIm36DcMXs/L8gldyQltRUoexYGL07BiIkIPCCXYguJg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=tenstorrent.com; spf=pass smtp.mailfrom=tenstorrent.com; dkim=pass (2048-bit key) header.d=tenstorrent.com header.i=@tenstorrent.com header.b=eu7LLvBb; arc=none smtp.client-ip=209.85.210.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=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="eu7LLvBb" Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-6eb86aeeb2cso1615504a34.3 for ; Fri, 26 Apr 2024 17:10:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tenstorrent.com; s=google; t=1714176657; x=1714781457; 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=Ne2ZlIQCKfOcvHLY/0x4Jxjg9FtmWMk3FQpX6nDI9Nw=; b=eu7LLvBb3DVno4hfqm4MQ4euqucp0XUI9dGrNmczAqNYWUXXo5HH25fiWp/yYp6oJQ vnnTnt8exxb1Uzaw03ZeLeBS1X5JQu/a3+2lR6KXUUgW2NtVvCfQIs6QEdhOi3hVV5uA wGArVTvTH9cGtuqOSZr0P3ZolABLt5k7H/Dyr8lRuZfocjuiOXV4HQOhGUcbQMPuY6g+ UYdCNbc8kpVP+IU8J9wy9RRCtvX2uCTe2RXKqvhBb7o8aTAQ+WJioiB/q/2c572vF67O DfU2KMNxXwNU5R8xjg4H8OM4h7l9iSQ2JfHmO3Y0JK5PpPZ0UKQyhDHClkLZAfv1lgCj nGYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714176657; x=1714781457; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ne2ZlIQCKfOcvHLY/0x4Jxjg9FtmWMk3FQpX6nDI9Nw=; b=kWZPxCSBsq+EMzOCBDAg1Sj21k6VYzUeyRj8izlwA4n+B1CT/elioEYwJ5YvPQBSES f7XSkjVngvwobY9kvtoFoy8XppK3i6qYcJyyPY79Irw0avUSoqtZ1jascvRRi7B9Vk5D lbz9Pw7AE00SUqQHs7yZtnx8xaleH/SZj0YjruOhFstRREQKcrXy18clFLF3DlR+IAow 501ISbgT2tFogjSdRBSZXvaJln5yhSE5iVNVd7KcPV4Pi4zMkR1R01sb5lW41P0Df318 vMTzTiYifEn0vnqmDwsORyru/RZiT4xYhHPQuie/akr/zcCOLj+nWmA5oNXYPOtcJTJE dTMg== X-Forwarded-Encrypted: i=1; AJvYcCXEVv+HL4C7NX1TU+NcDvDsiiET+0CmL3SVFc9tEN5n+xgEhmuyDKWy6ZZlqMRUMKs4k44x7vXpnMF0CtHgViZ7cgbbgpcMenSqPp2t X-Gm-Message-State: AOJu0YzE4IM9npCOzg2R5DQgACepdVGrfIHgm78bMPwePM9MRHMiI+Jd 21UnDXmEDnBnrWpE4nC3gsjw1K1jAjv+mW9s/Aasm2jQ+WW4/Qrv08DUpIpG0vs= X-Google-Smtp-Source: AGHT+IFEwayluKHwV05i8kdIrdip2UfftX1+AzDdMz+XQYq6+Oakxtv8vS30/7M52GUrg3LnQ3UynQ== X-Received: by 2002:a05:6830:10d0:b0:6eb:7c52:ed04 with SMTP id z16-20020a05683010d000b006eb7c52ed04mr1648346oto.5.1714176657534; Fri, 26 Apr 2024 17:10:57 -0700 (PDT) Received: from [127.0.1.1] ([2601:1c2:1802:170:3569:7ce4:94b8:1691]) by smtp.gmail.com with ESMTPSA id w1-20020a6556c1000000b005f3d54c0a57sm6061883pgs.49.2024.04.26.17.10.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 17:10:57 -0700 (PDT) From: Drew Fustini Date: Fri, 26 Apr 2024 17:10:35 -0700 Subject: [PATCH RFC v2 2/4] clk: thead: Add support for T-Head TH1520 AP_SUBSYS clocks 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: <20240426-th1520-clk-v2-v2-2-96b829e6fcee@tenstorrent.com> References: <20240426-th1520-clk-v2-v2-0-96b829e6fcee@tenstorrent.com> In-Reply-To: <20240426-th1520-clk-v2-v2-0-96b829e6fcee@tenstorrent.com> To: Jisheng Zhang , Guo Ren , Fu Wei , Yangtao Li , Thomas Bonnefille , Emil Renner Berthing , Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Drew Fustini , Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: linux-riscv@lists.infradead.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1714176654; l=31883; i=dfustini@tenstorrent.com; s=20230430; h=from:subject:message-id; bh=FxwfDsXMNi6nOG8OLcKaN3n7jcJsSjXmtP4iQAH+beU=; b=FwtvrSPJoN6DnHiN8QEGflIRrBv9xYT9/o5vvyhrE6jSaBHYwdoqX/mOr2FP8mXOhiKPSFc+V moK0CT/RQWzBn3WTNoYuDTgAbBW0pet+Bvyw/qDG+5a+rpzVXqlhZee X-Developer-Key: i=dfustini@tenstorrent.com; a=ed25519; pk=p3GKE9XFmjhwAayAHG4U108yag7V8xQVd4zJLdW0g7g= Add support for the AP sub-system clock controller in the T-Head TH1520. This include CPU, DPU, GMAC and TEE PLLs. Link: https://openbeagle.org/beaglev-ahead/beaglev-ahead/-/blob/main/docs/T= H1520%20System%20User%20Manual.pdf Co-developed-by: Yangtao Li Signed-off-by: Yangtao Li Co-developed-by: Jisheng Zhang Signed-off-by: Jisheng Zhang Signed-off-by: Drew Fustini Tested-by: Thomas Bonnefille --- MAINTAINERS | 1 + drivers/clk/Kconfig | 1 + drivers/clk/Makefile | 1 + drivers/clk/thead/Kconfig | 12 + drivers/clk/thead/Makefile | 2 + drivers/clk/thead/clk-th1520-ap.c | 1018 +++++++++++++++++++++++++++++++++= ++++ 6 files changed, 1035 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 51d550cb1329..acd55e12d768 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19025,6 +19025,7 @@ L: linux-riscv@lists.infradead.org S: Maintained F: Documentation/devicetree/bindings/clock/thead,th1520-clk-ap.yaml F: arch/riscv/boot/dts/thead/ +F: drivers/clk/thead/clk-th1520-ap.c F: include/dt-bindings/clock/thead,th1520-clk-ap.h =20 RNBD BLOCK DRIVERS diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig index 50af5fc7f570..c9057e41df34 100644 --- a/drivers/clk/Kconfig +++ b/drivers/clk/Kconfig @@ -494,6 +494,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/thead/Kconfig" source "drivers/clk/stm32/Kconfig" source "drivers/clk/ti/Kconfig" source "drivers/clk/uniphier/Kconfig" diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index 14fa8d4ecc1f..2eafc268f498 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile @@ -126,6 +126,7 @@ obj-y +=3D starfive/ obj-$(CONFIG_ARCH_SUNXI) +=3D sunxi/ obj-y +=3D sunxi-ng/ obj-$(CONFIG_ARCH_TEGRA) +=3D tegra/ +obj-$(CONFIG_ARCH_THEAD) +=3D thead/ obj-y +=3D ti/ obj-$(CONFIG_CLK_UNIPHIER) +=3D uniphier/ obj-$(CONFIG_ARCH_U8500) +=3D ux500/ diff --git a/drivers/clk/thead/Kconfig b/drivers/clk/thead/Kconfig new file mode 100644 index 000000000000..1710d50bf9d4 --- /dev/null +++ b/drivers/clk/thead/Kconfig @@ -0,0 +1,12 @@ +#SPDX-License-Identifier: GPL-2.0 + +config CLK_THEAD_TH1520_AP + bool "T-HEAD TH1520 AP clock support" + depends on ARCH_THEAD || COMPILE_TEST + default ARCH_THEAD + select REGMAP_MMIO + help + Say yes here to support the AP sub system clock controller + on the T-HEAD TH1520 SoC. This includes configuration of + both CPU PLLs, both DPU PLLs as well as the GMAC, VIDEO, + and TEE PLLs. diff --git a/drivers/clk/thead/Makefile b/drivers/clk/thead/Makefile new file mode 100644 index 000000000000..7ee0bec1f251 --- /dev/null +++ b/drivers/clk/thead/Makefile @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_CLK_THEAD_TH1520_AP) +=3D clk-th1520-ap.o diff --git a/drivers/clk/thead/clk-th1520-ap.c b/drivers/clk/thead/clk-th15= 20-ap.c new file mode 100644 index 000000000000..21040e7d280c --- /dev/null +++ b/drivers/clk/thead/clk-th1520-ap.c @@ -0,0 +1,1018 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2023 Jisheng Zhang + * Copyright (C) 2023 Vivo Communication Technology Co. Ltd. + * Authors: Yangtao Li + */ + +#include +#include +#include +#include +#include +#include + +struct ccu_internal { + u8 shift; + u8 width; +}; + +struct ccu_div_internal { + u8 shift; + u8 width; + u32 flags; +}; + +struct ccu_common { + struct regmap *map; + u16 reg; + struct clk_hw hw; +}; + +struct ccu_mux { + struct ccu_internal mux; + struct ccu_common common; +}; + +struct ccu_gate { + u32 enable; + struct ccu_common common; +}; + +struct ccu_div { + u32 enable; + struct ccu_div_internal div; + struct ccu_internal mux; + struct ccu_common common; +}; + +/* + * struct ccu_mdiv - Definition of an M-D-I-V clock + * + * Clocks based on the formula (parent * M) / (D * I * V) + */ +struct ccu_mdiv { + struct ccu_internal m; + struct ccu_internal d; + struct ccu_internal i; + struct ccu_internal v; + struct ccu_common common; +}; + +#define TH_CCU_ARG(_shift, _width) \ + { \ + .shift =3D _shift, \ + .width =3D _width, \ + } + +#define TH_CCU_DIV_FLAGS(_shift, _width, _flags) \ + { \ + .shift =3D _shift, \ + .width =3D _width, \ + .flags =3D _flags, \ + } + +#define CCU_GATE(_struct, _name, _parent, _reg, _gate, _flags) \ + struct ccu_gate _struct =3D { \ + .enable =3D _gate, \ + .common =3D { \ + .reg =3D _reg, \ + .hw.init =3D CLK_HW_INIT(_name, \ + _parent, \ + &ccu_gate_ops, \ + _flags), \ + } \ + } + +static inline struct ccu_common *hw_to_ccu_common(struct clk_hw *hw) +{ + return container_of(hw, struct ccu_common, hw); +} + +static inline struct ccu_mux *hw_to_ccu_mux(struct clk_hw *hw) +{ + struct ccu_common *common =3D hw_to_ccu_common(hw); + + return container_of(common, struct ccu_mux, common); +} + +static inline struct ccu_mdiv *hw_to_ccu_mdiv(struct clk_hw *hw) +{ + struct ccu_common *common =3D hw_to_ccu_common(hw); + + return container_of(common, struct ccu_mdiv, common); +} + +static inline struct ccu_div *hw_to_ccu_div(struct clk_hw *hw) +{ + struct ccu_common *common =3D hw_to_ccu_common(hw); + + return container_of(common, struct ccu_div, common); +} + +static inline struct ccu_gate *hw_to_ccu_gate(struct clk_hw *hw) +{ + struct ccu_common *common =3D hw_to_ccu_common(hw); + + return container_of(common, struct ccu_gate, common); +} + +static u8 ccu_get_parent_helper(struct ccu_common *common, + struct ccu_internal *mux) +{ + unsigned int val; + u8 parent; + + regmap_read(common->map, common->reg, &val); + parent =3D val >> mux->shift; + parent &=3D GENMASK(mux->width - 1, 0); + + return parent; +} + +static int ccu_set_parent_helper(struct ccu_common *common, + struct ccu_internal *mux, + u8 index) +{ + return regmap_update_bits(common->map, common->reg, + GENMASK(mux->width - 1, 0) << mux->shift, + index << mux->shift); +} + +static u8 ccu_mux_get_parent(struct clk_hw *hw) +{ + struct ccu_mux *cm =3D hw_to_ccu_mux(hw); + + return ccu_get_parent_helper(&cm->common, &cm->mux); +} + +static int ccu_mux_set_parent(struct clk_hw *hw, u8 index) +{ + struct ccu_mux *cm =3D hw_to_ccu_mux(hw); + + return ccu_set_parent_helper(&cm->common, &cm->mux, index); +} + +static const struct clk_ops ccu_mux_ops =3D { + .get_parent =3D ccu_mux_get_parent, + .set_parent =3D ccu_mux_set_parent, + .determine_rate =3D __clk_mux_determine_rate, +}; + +void ccu_disable_helper(struct ccu_common *common, u32 gate) +{ + if (!gate) + return; + + regmap_update_bits(common->map, common->reg, + gate, ~gate); +} + +int ccu_enable_helper(struct ccu_common *common, u32 gate) +{ + if (!gate) + return 0; + + return regmap_update_bits(common->map, common->reg, + gate, gate); +} + +static int ccu_is_enabled_helper(struct ccu_common *common, u32 gate) +{ + unsigned int val; + + if (!gate) + return true; + + regmap_read(common->map, common->reg, &val); + return val & gate; +} + +static int ccu_gate_is_enabled(struct clk_hw *hw) +{ + struct ccu_gate *cg =3D hw_to_ccu_gate(hw); + + return ccu_is_enabled_helper(&cg->common, cg->enable); +} + +static void ccu_gate_disable(struct clk_hw *hw) +{ + struct ccu_gate *cg =3D hw_to_ccu_gate(hw); + + ccu_disable_helper(&cg->common, cg->enable); +} + +static int ccu_gate_enable(struct clk_hw *hw) +{ + struct ccu_gate *cg =3D hw_to_ccu_gate(hw); + + return ccu_enable_helper(&cg->common, cg->enable); +} + +static const struct clk_ops ccu_gate_ops =3D { + .disable =3D ccu_gate_disable, + .enable =3D ccu_gate_enable, + .is_enabled =3D ccu_gate_is_enabled, +}; + +static unsigned long ccu_div_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct ccu_div *cd =3D hw_to_ccu_div(hw); + unsigned int val; + + regmap_read(cd->common.map, cd->common.reg, &val); + val =3D val >> cd->div.shift; + val &=3D GENMASK(cd->div.width - 1, 0); + + val =3D divider_recalc_rate(hw, parent_rate, val, NULL, + cd->div.flags, cd->div.width); + + return val; +} + +static u8 ccu_div_get_parent(struct clk_hw *hw) +{ + struct ccu_div *cd =3D hw_to_ccu_div(hw); + + return ccu_get_parent_helper(&cd->common, &cd->mux); +} + +static int ccu_div_set_parent(struct clk_hw *hw, u8 index) +{ + struct ccu_div *cd =3D hw_to_ccu_div(hw); + + return ccu_set_parent_helper(&cd->common, &cd->mux, index); +} + +static void ccu_div_disable(struct clk_hw *hw) +{ + struct ccu_div *cd =3D hw_to_ccu_div(hw); + + ccu_disable_helper(&cd->common, cd->enable); +} + +static int ccu_div_enable(struct clk_hw *hw) +{ + struct ccu_div *cd =3D hw_to_ccu_div(hw); + + return ccu_enable_helper(&cd->common, cd->enable); +} + +static int ccu_div_is_enabled(struct clk_hw *hw) +{ + struct ccu_div *cd =3D hw_to_ccu_div(hw); + + return ccu_is_enabled_helper(&cd->common, cd->enable); +} + +static const struct clk_ops ccu_div_ops =3D { + .disable =3D ccu_div_disable, + .enable =3D ccu_div_enable, + .is_enabled =3D ccu_div_is_enabled, + .get_parent =3D ccu_div_get_parent, + .set_parent =3D ccu_div_set_parent, + .recalc_rate =3D ccu_div_recalc_rate, + .determine_rate =3D clk_hw_determine_rate_no_reparent, +}; + +static unsigned long ccu_mdiv_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct ccu_mdiv *mdiv =3D hw_to_ccu_mdiv(hw); + unsigned long div, rate =3D parent_rate; + unsigned int m, d, i, v, val; + + regmap_read(mdiv->common.map, mdiv->common.reg, &val); + + m =3D val >> mdiv->m.shift; + m &=3D GENMASK(mdiv->m.width - 1, 0); + + d =3D val >> mdiv->d.shift; + d &=3D GENMASK(mdiv->d.width - 1, 0); + + i =3D val >> mdiv->i.shift; + i &=3D GENMASK(mdiv->i.width - 1, 0); + + v =3D val >> mdiv->v.shift; + v &=3D GENMASK(mdiv->v.width - 1, 0); + + rate =3D parent_rate * m; + div =3D d * i * v; + do_div(rate, div); + + return rate; +} + +static const struct clk_ops clk_mdiv_ops =3D { + .recalc_rate =3D ccu_mdiv_recalc_rate, +}; + +static struct ccu_mdiv cpu_pll0_clk =3D { + .m =3D TH_CCU_ARG(8, 12), + .d =3D TH_CCU_ARG(24, 3), + .i =3D TH_CCU_ARG(20, 3), + .v =3D TH_CCU_ARG(0, 6), + .common =3D { + .reg =3D 0x000, + .hw.init =3D CLK_HW_INIT("cpu-pll0", "osc_24m", + &clk_mdiv_ops, + 0), + }, +}; + +static struct ccu_mdiv cpu_pll1_clk =3D { + .m =3D TH_CCU_ARG(8, 12), + .d =3D TH_CCU_ARG(24, 3), + .i =3D TH_CCU_ARG(20, 3), + .v =3D TH_CCU_ARG(0, 6), + .common =3D { + .reg =3D 0x010, + .hw.init =3D CLK_HW_INIT("cpu-pll1", "osc_24m", + &clk_mdiv_ops, + 0), + }, +}; + +static struct ccu_mdiv gmac_pll_clk =3D { + .m =3D TH_CCU_ARG(8, 12), + .d =3D TH_CCU_ARG(24, 3), + .i =3D TH_CCU_ARG(20, 3), + .v =3D TH_CCU_ARG(0, 6), + .common =3D { + .reg =3D 0x020, + .hw.init =3D CLK_HW_INIT("gmac-pll", "osc_24m", + &clk_mdiv_ops, + 0), + }, +}; + +static struct ccu_mdiv video_pll_clk =3D { + .m =3D TH_CCU_ARG(8, 12), + .d =3D TH_CCU_ARG(24, 3), + .i =3D TH_CCU_ARG(20, 3), + .v =3D TH_CCU_ARG(0, 6), + .common =3D { + .reg =3D 0x030, + .hw.init =3D CLK_HW_INIT("video-pll", "osc_24m", + &clk_mdiv_ops, + 0), + }, +}; + +static struct ccu_mdiv dpu0_pll_clk =3D { + .m =3D TH_CCU_ARG(8, 12), + .d =3D TH_CCU_ARG(24, 3), + .i =3D TH_CCU_ARG(20, 3), + .v =3D TH_CCU_ARG(0, 6), + .common =3D { + .reg =3D 0x040, + .hw.init =3D CLK_HW_INIT("dpu0-pll", "osc_24m", + &clk_mdiv_ops, + 0), + }, +}; + +static struct ccu_mdiv dpu1_pll_clk =3D { + .m =3D TH_CCU_ARG(8, 12), + .d =3D TH_CCU_ARG(24, 3), + .i =3D TH_CCU_ARG(20, 3), + .v =3D TH_CCU_ARG(0, 6), + .common =3D { + .reg =3D 0x050, + .hw.init =3D CLK_HW_INIT("dpu1-pll", "osc_24m", + &clk_mdiv_ops, + 0), + }, +}; + +static struct ccu_mdiv tee_pll_clk =3D { + .m =3D TH_CCU_ARG(8, 12), + .d =3D TH_CCU_ARG(24, 3), + .i =3D TH_CCU_ARG(20, 3), + .v =3D TH_CCU_ARG(0, 6), + .common =3D { + .reg =3D 0x060, + .hw.init =3D CLK_HW_INIT("tee-pll", "osc_24m", + &clk_mdiv_ops, + 0), + }, +}; + +static const char * const c910_i0_parents[] =3D { "cpu-pll0", "osc_24m" }; +struct ccu_mux c910_i0_clk =3D { + .mux =3D TH_CCU_ARG(1, 1), + .common =3D { + .reg =3D 0x100, + .hw.init =3D CLK_HW_INIT_PARENTS("c910-i0", + c910_i0_parents, + &ccu_mux_ops, + 0), + } +}; + +static const char * const c910_parents[] =3D { "c910-i0", "cpu-pll1" }; +struct ccu_mux c910_clk =3D { + .mux =3D TH_CCU_ARG(0, 1), + .common =3D { + .reg =3D 0x100, + .hw.init =3D CLK_HW_INIT_PARENTS("c910", + c910_parents, + &ccu_mux_ops, + 0), + } +}; + +static CCU_GATE(brom_clk, "brom", "ahb2-cpusys-hclk", + 0x100, BIT(4), 0); + +static CCU_GATE(bmu_clk, "bmu", "axi4-cpusys2-aclk", + 0x100, BIT(5), 0); + +static const char * const ahb2_cpusys_parents[] =3D { "gmac-pll", "osc_24m= " }; +static struct ccu_div ahb2_cpusys_hclk =3D { + .div =3D TH_CCU_DIV_FLAGS(0, 3, CLK_DIVIDER_ONE_BASED), + .mux =3D TH_CCU_ARG(5, 1), + .common =3D { + .reg =3D 0x120, + .hw.init =3D CLK_HW_INIT_PARENTS("ahb2-cpusys-hclk", + ahb2_cpusys_parents, + &ccu_div_ops, + 0), + }, +}; + +static struct ccu_div apb3_cpusys_pclk =3D { + .div =3D TH_CCU_ARG(0, 3), + .common =3D { + .reg =3D 0x130, + .hw.init =3D CLK_HW_INIT("apb3-cpusys-pclk", "ahb2-cpusys-hclk", + &ccu_div_ops, + 0), + }, +}; + +static struct ccu_div axi4_cpusys2_aclk =3D { + .div =3D TH_CCU_DIV_FLAGS(0, 3, CLK_DIVIDER_ONE_BASED), + .common =3D { + .reg =3D 0x134, + .hw.init =3D CLK_HW_INIT("axi4-cpusys2-aclk", "gmac-pll", + &ccu_div_ops, + 0), + }, +}; + +static CCU_GATE(aon2cpu_a2x_clk, "aon2cpu-a2x", "axi4-cpusys2-aclk", + 0x134, BIT(8), 0); + +static CCU_GATE(x2x_cpusys_clk, "x2x-cpusys", "axi4-cpusys2-aclk", + 0x134, BIT(7), 0); + +static const char * const axi_parents[] =3D { "video-pll", "osc_24m" }; +static struct ccu_div axi_aclk =3D { + .div =3D TH_CCU_DIV_FLAGS(0, 4, CLK_DIVIDER_ONE_BASED), + .mux =3D TH_CCU_ARG(5, 1), + .common =3D { + .reg =3D 0x138, + .hw.init =3D CLK_HW_INIT_PARENTS("axi-aclk", + axi_parents, + &ccu_div_ops, + 0), + }, +}; + +static CCU_GATE(cpu2aon_x2h_clk, "cpu2aon-x2h", "axi-aclk", + 0x138, BIT(8), 0); + +static const char * const perisys_ahb_hclk_parents[] =3D { "gmac-pll", "os= c_24m" }; +static struct ccu_div perisys_ahb_hclk =3D { + .enable =3D BIT(6), + .div =3D TH_CCU_DIV_FLAGS(0, 4, CLK_DIVIDER_ONE_BASED), + .mux =3D TH_CCU_ARG(5, 1), + .common =3D { + .reg =3D 0x140, + .hw.init =3D CLK_HW_INIT_PARENTS("perisys-ahb-hclk", + perisys_ahb_hclk_parents, + &ccu_div_ops, + 0), + }, +}; + +static CCU_GATE(cpu2peri_x2h_clk, "cpu2peri-x2h", "axi4-cpusys2-aclk", + 0x140, BIT(9), 0); + +static struct ccu_div perisys_apb_pclk =3D { + .div =3D TH_CCU_ARG(0, 3), + .common =3D { + .reg =3D 0x150, + .hw.init =3D CLK_HW_INIT("perisys-apb-pclk", "perisys-ahb-hclk", + &ccu_div_ops, + 0), + }, +}; + +static struct ccu_div peri2sys_apb_pclk =3D { + .div =3D TH_CCU_DIV_FLAGS(4, 3, CLK_DIVIDER_ONE_BASED), + .common =3D { + .reg =3D 0x150, + .hw.init =3D CLK_HW_INIT("peri2sys-apb-pclk", + "gmac-pll", + &ccu_div_ops, + 0), + }, +}; + +static CCU_GATE(perisys_apb1_hclk, "perisys-apb1-hclk", "perisys-ahb-hclk", + 0x150, BIT(9), 0); + +static CCU_GATE(perisys_apb2_hclk, "perisys-apb2-hclk", "perisys-ahb-hclk", + 0x150, BIT(10), 0); + +static CCU_GATE(perisys_apb3_hclk, "perisys-apb3-hclk", "perisys-ahb-hclk", + 0x150, BIT(11), 0); + +static CCU_GATE(perisys_apb4_hclk, "perisys-apb4-hclk", "perisys-ahb-hclk", + 0x150, BIT(12), 0); + +static CLK_FIXED_FACTOR_FW_NAME(osc12m_clk, "osc_12m", "osc_24m", 2, 1, 0); + +static const char * const out_parents[] =3D { "osc_24m", "osc_12m" }; + +static struct ccu_div out1_clk =3D { + .enable =3D BIT(5), + .div =3D TH_CCU_DIV_FLAGS(0, 3, CLK_DIVIDER_ONE_BASED), + .mux =3D TH_CCU_ARG(4, 1), + .common =3D { + .reg =3D 0x1b4, + .hw.init =3D CLK_HW_INIT_PARENTS("out1", + out_parents, + &ccu_div_ops, + 0), + }, +}; + +static struct ccu_div out2_clk =3D { + .enable =3D BIT(5), + .div =3D TH_CCU_DIV_FLAGS(0, 3, CLK_DIVIDER_ONE_BASED), + .mux =3D TH_CCU_ARG(4, 1), + .common =3D { + .reg =3D 0x1b8, + .hw.init =3D CLK_HW_INIT_PARENTS("out2", + out_parents, + &ccu_div_ops, + 0), + }, +}; + +static struct ccu_div out3_clk =3D { + .enable =3D BIT(5), + .div =3D TH_CCU_DIV_FLAGS(0, 3, CLK_DIVIDER_ONE_BASED), + .mux =3D TH_CCU_ARG(4, 1), + .common =3D { + .reg =3D 0x1bc, + .hw.init =3D CLK_HW_INIT_PARENTS("out3", + out_parents, + &ccu_div_ops, + 0), + }, +}; + +static struct ccu_div out4_clk =3D { + .enable =3D BIT(5), + .div =3D TH_CCU_DIV_FLAGS(0, 3, CLK_DIVIDER_ONE_BASED), + .mux =3D TH_CCU_ARG(4, 1), + .common =3D { + .reg =3D 0x1c0, + .hw.init =3D CLK_HW_INIT_PARENTS("out4", + out_parents, + &ccu_div_ops, + 0), + }, +}; + +static const char * const apb_parents[] =3D { "gmac-pll", "osc_24m" }; +static struct ccu_div apb_pclk =3D { + .enable =3D BIT(5), + .div =3D TH_CCU_DIV_FLAGS(0, 4, CLK_DIVIDER_ONE_BASED), + .mux =3D TH_CCU_ARG(7, 1), + .common =3D { + .reg =3D 0x1c4, + .hw.init =3D CLK_HW_INIT_PARENTS("apb-pclk", + apb_parents, + &ccu_div_ops, + 0), + }, +}; + +static const char * const npu_parents[] =3D { "gmac-pll", "video-pll" }; +static struct ccu_div npu_clk =3D { + .enable =3D BIT(4), + .div =3D TH_CCU_DIV_FLAGS(0, 3, CLK_DIVIDER_ONE_BASED), + .mux =3D TH_CCU_ARG(6, 1), + .common =3D { + .reg =3D 0x1c8, + .hw.init =3D CLK_HW_INIT_PARENTS("npu", + npu_parents, + &ccu_div_ops, + 0), + }, +}; + +static CCU_GATE(npu_axi_clk, "npu-axi", "npu-ahb", + 0x1c8, BIT(5), 0); + +static struct ccu_div vi_clk =3D { + .div =3D TH_CCU_DIV_FLAGS(16, 4, CLK_DIVIDER_ONE_BASED), + .common =3D { + .reg =3D 0x1d0, + .hw.init =3D CLK_HW_INIT("vi", + "video-pll", + &ccu_div_ops, + 0), + }, +}; + +static struct ccu_div vi_ahb_clk =3D { + .div =3D TH_CCU_DIV_FLAGS(0, 4, CLK_DIVIDER_ONE_BASED), + .common =3D { + .reg =3D 0x1d0, + .hw.init =3D CLK_HW_INIT("vi-ahb", + "video-pll", + &ccu_div_ops, + 0), + }, +}; + +static struct ccu_div vo_axi_clk =3D { + .enable =3D BIT(5), + .div =3D TH_CCU_DIV_FLAGS(0, 4, CLK_DIVIDER_ONE_BASED), + .common =3D { + .reg =3D 0x1dc, + .hw.init =3D CLK_HW_INIT("vo-axi", + "video-pll", + &ccu_div_ops, + 0), + }, +}; + +static struct ccu_div vp_apb_clk =3D { + .div =3D TH_CCU_DIV_FLAGS(0, 3, CLK_DIVIDER_ONE_BASED), + .common =3D { + .reg =3D 0x1e0, + .hw.init =3D CLK_HW_INIT("vp-apb", + "gmac-pll", + &ccu_div_ops, + 0), + }, +}; + +static struct ccu_div vp_axi_clk =3D { + .enable =3D BIT(15), + .div =3D TH_CCU_DIV_FLAGS(8, 4, CLK_DIVIDER_ONE_BASED), + .common =3D { + .reg =3D 0x1e0, + .hw.init =3D CLK_HW_INIT("vp-axi", + "video-pll", + &ccu_div_ops, + 0), + }, +}; + +static CCU_GATE(cpu2vp_clk, "cpu2vp", "axi-aclk", + 0x1e0, BIT(13), 0); + +static struct ccu_div venc_clk =3D { + .enable =3D BIT(5), + .div =3D TH_CCU_DIV_FLAGS(0, 3, CLK_DIVIDER_ONE_BASED), + .common =3D { + .reg =3D 0x1e4, + .hw.init =3D CLK_HW_INIT("venc", + "gmac-pll", + &ccu_div_ops, + 0), + }, +}; + +static struct ccu_div dpu0_clk =3D { + .div =3D TH_CCU_DIV_FLAGS(0, 8, CLK_DIVIDER_ONE_BASED), + .common =3D { + .reg =3D 0x1e8, + .hw.init =3D CLK_HW_INIT("dpu0", + "dpu0-pll", + &ccu_div_ops, + 0), + }, +}; + +static struct ccu_div dpu1_clk =3D { + .div =3D TH_CCU_DIV_FLAGS(0, 8, CLK_DIVIDER_ONE_BASED), + .common =3D { + .reg =3D 0x1ec, + .hw.init =3D CLK_HW_INIT("dpu1", + "dpu1-pll", + &ccu_div_ops, + 0), + }, +}; + +static CCU_GATE(emmc_sdio_clk, "emmc-sdio", "video-pll", 0x204, BIT(30), 0= ); +static CCU_GATE(gmac1_clk, "gmac1", "gmac-pll", 0x204, BIT(26), 0); +static CCU_GATE(padctrl1_clk, "padctrl1", "perisys-apb-pclk", 0x204, BIT(2= 4), 0); +static CCU_GATE(dsmart_clk, "dsmart", "perisys-apb-pclk", 0x204, BIT(23), = 0); +static CCU_GATE(padctrl0_clk, "padctrl0", "perisys-apb-pclk", 0x204, BIT(2= 2), 0); +static CCU_GATE(gmac_axi_clk, "gmac-axi", "axi4-cpusys2-aclk", 0x204, BIT(= 21), 0); +static CCU_GATE(gpio3_clk, "gpio3-clk", "peri2sys-apb-pclk", 0x204, BIT(20= ), 0); +static CCU_GATE(gmac0_clk, "gmac0", "gmac-pll", 0x204, BIT(19), 0); +static CCU_GATE(pwm_clk, "pwm", "perisys-apb-pclk", 0x204, BIT(18), 0); +static CCU_GATE(qspi0_clk, "qspi0", "video-pll", 0x204, BIT(17), 0); +static CCU_GATE(qspi1_clk, "qspi1", "video-pll", 0x204, BIT(16), 0); +static CCU_GATE(spi_clk, "spi", "video-pll", 0x204, BIT(15), 0); +static CCU_GATE(uart0_pclk, "uart0-pclk", "perisys-apb-pclk", 0x204, BIT(1= 4), 0); +static CCU_GATE(uart1_pclk, "uart1-pclk", "perisys-apb-pclk", 0x204, BIT(1= 3), 0); +static CCU_GATE(uart2_pclk, "uart2-pclk", "perisys-apb-pclk", 0x204, BIT(1= 2), 0); +static CCU_GATE(uart3_pclk, "uart3-pclk", "perisys-apb-pclk", 0x204, BIT(1= 1), 0); +static CCU_GATE(uart4_pclk, "uart4-pclk", "perisys-apb-pclk", 0x204, BIT(1= 0), 0); +static CCU_GATE(uart5_pclk, "uart5-pclk", "perisys-apb-pclk", 0x204, BIT(9= ), 0); +static CCU_GATE(gpio0_clk, "gpio0-clk", "perisys-apb-pclk", 0x204, BIT(8),= 0); +static CCU_GATE(gpio1_clk, "gpio1-clk", "perisys-apb-pclk", 0x204, BIT(7),= 0); +static CCU_GATE(gpio2_clk, "gpio2-clk", "peri2sys-apb-pclk", 0x204, BIT(6)= , 0); +static CCU_GATE(i2c0_clk, "i2c0", "perisys-apb-pclk", 0x204, BIT(5), 0); +static CCU_GATE(i2c1_clk, "i2c1", "perisys-apb-pclk", 0x204, BIT(4), 0); +static CCU_GATE(i2c2_clk, "i2c2", "perisys-apb-pclk", 0x204, BIT(3), 0); +static CCU_GATE(i2c3_clk, "i2c3", "perisys-apb-pclk", 0x204, BIT(2), 0); +static CCU_GATE(i2c4_clk, "i2c4", "perisys-apb-pclk", 0x204, BIT(1), 0); +static CCU_GATE(i2c5_clk, "i2c5", "perisys-apb-pclk", 0x204, BIT(0), 0); + +static CCU_GATE(spinlock_clk, "spinlock", "ahb2-cpusys-hclk", 0x208, BIT(1= 0), 0); +static CCU_GATE(dma_clk, "dma", "axi4-cpusys2-aclk", 0x208, BIT(8), 0); +static CCU_GATE(mbox0_clk, "mbox0", "apb3-cpusys-pclk", 0x208, BIT(7), 0); +static CCU_GATE(mbox1_clk, "mbox1", "apb3-cpusys-pclk", 0x208, BIT(6), 0); +static CCU_GATE(mbox2_clk, "mbox2", "apb3-cpusys-pclk", 0x208, BIT(5), 0); +static CCU_GATE(mbox3_clk, "mbox3", "apb3-cpusys-pclk", 0x208, BIT(4), 0); +static CCU_GATE(wdt0_clk, "wdt0", "apb3-cpusys-pclk", 0x208, BIT(3), 0); +static CCU_GATE(wdt1_clk, "wdt1", "apb3-cpusys-pclk", 0x208, BIT(2), 0); +static CCU_GATE(timer0_clk, "timer0", "apb3-cpusys-pclk", 0x208, BIT(1), 0= ); +static CCU_GATE(timer1_clk, "timer1", "apb3-cpusys-pclk", 0x208, BIT(0), 0= ); + +static CCU_GATE(sram0_clk, "sram0", "axi-aclk", 0x20c, BIT(4), 0); +static CCU_GATE(sram1_clk, "sram1", "axi-aclk", 0x20c, BIT(3), 0); +static CCU_GATE(sram2_clk, "sram2", "axi-aclk", 0x20c, BIT(2), 0); +static CCU_GATE(sram3_clk, "sram3", "axi-aclk", 0x20c, BIT(1), 0); + +static CLK_FIXED_FACTOR_HW(gmac_pll_clk_100m, "gmac-pll-clk-100m", + &gmac_pll_clk.common.hw, + 10, 1, 0); + +static const char * const uart_sclk_parents[] =3D { "gmac-pll-clk-100m", "= osc_24m" }; +struct ccu_mux uart_sclk =3D { + .mux =3D TH_CCU_ARG(0, 1), + .common =3D { + .reg =3D 0x210, + .hw.init =3D CLK_HW_INIT_PARENTS("uart-sclk", + uart_sclk_parents, + &ccu_mux_ops, + 0), + } +}; + +static struct ccu_common *th1520_clks[] =3D { + &cpu_pll0_clk.common, + &cpu_pll1_clk.common, + &gmac_pll_clk.common, + &video_pll_clk.common, + &dpu0_pll_clk.common, + &dpu1_pll_clk.common, + &tee_pll_clk.common, + &c910_i0_clk.common, + &c910_clk.common, + &brom_clk.common, + &bmu_clk.common, + &ahb2_cpusys_hclk.common, + &apb3_cpusys_pclk.common, + &axi4_cpusys2_aclk.common, + &aon2cpu_a2x_clk.common, + &x2x_cpusys_clk.common, + &axi_aclk.common, + &cpu2aon_x2h_clk.common, + &perisys_ahb_hclk.common, + &cpu2peri_x2h_clk.common, + &perisys_apb_pclk.common, + &peri2sys_apb_pclk.common, + &perisys_apb1_hclk.common, + &perisys_apb2_hclk.common, + &perisys_apb3_hclk.common, + &perisys_apb4_hclk.common, + &out1_clk.common, + &out2_clk.common, + &out3_clk.common, + &out4_clk.common, + &apb_pclk.common, + &npu_clk.common, + &npu_axi_clk.common, + &vi_clk.common, + &vi_ahb_clk.common, + &vo_axi_clk.common, + &vp_apb_clk.common, + &vp_axi_clk.common, + &cpu2vp_clk.common, + &venc_clk.common, + &dpu0_clk.common, + &dpu1_clk.common, + &emmc_sdio_clk.common, + &gmac1_clk.common, + &padctrl1_clk.common, + &dsmart_clk.common, + &padctrl0_clk.common, + &gmac_axi_clk.common, + &gpio3_clk.common, + &gmac0_clk.common, + &pwm_clk.common, + &qspi0_clk.common, + &qspi1_clk.common, + &spi_clk.common, + &uart0_pclk.common, + &uart1_pclk.common, + &uart2_pclk.common, + &uart3_pclk.common, + &uart4_pclk.common, + &uart5_pclk.common, + &gpio0_clk.common, + &gpio1_clk.common, + &gpio2_clk.common, + &i2c0_clk.common, + &i2c1_clk.common, + &i2c2_clk.common, + &i2c3_clk.common, + &i2c4_clk.common, + &i2c5_clk.common, + &spinlock_clk.common, + &dma_clk.common, + &mbox0_clk.common, + &mbox1_clk.common, + &mbox2_clk.common, + &mbox3_clk.common, + &wdt0_clk.common, + &wdt1_clk.common, + &timer0_clk.common, + &timer1_clk.common, + &sram0_clk.common, + &sram1_clk.common, + &sram2_clk.common, + &sram3_clk.common, + &uart_sclk.common, +}; + +#define NR_CLKS (CLK_UART_SCLK + 1) + +static struct clk_hw_onecell_data th1520_hw_clks =3D { + .hws =3D { + [CLK_OSC12M] =3D &osc12m_clk.hw, + [CLK_CPU_PLL0] =3D &cpu_pll0_clk.common.hw, + [CLK_CPU_PLL1] =3D &cpu_pll1_clk.common.hw, + [CLK_GMAC_PLL] =3D &gmac_pll_clk.common.hw, + [CLK_VIDEO_PLL] =3D &video_pll_clk.common.hw, + [CLK_DPU0_PLL] =3D &dpu0_pll_clk.common.hw, + [CLK_DPU1_PLL] =3D &dpu1_pll_clk.common.hw, + [CLK_TEE_PLL] =3D &tee_pll_clk.common.hw, + [CLK_C910_I0] =3D &c910_i0_clk.common.hw, + [CLK_C910] =3D &c910_clk.common.hw, + [CLK_BROM] =3D &brom_clk.common.hw, + [CLK_BMU] =3D &bmu_clk.common.hw, + [CLK_AHB2_CPUSYS_HCLK] =3D &ahb2_cpusys_hclk.common.hw, + [CLK_APB3_CPUSYS_PCLK] =3D &apb3_cpusys_pclk.common.hw, + [CLK_AXI4_CPUSYS2_ACLK] =3D &axi4_cpusys2_aclk.common.hw, + [CLK_AON2CPU_A2X] =3D &aon2cpu_a2x_clk.common.hw, + [CLK_X2X_CPUSYS] =3D &x2x_cpusys_clk.common.hw, + [CLK_AXI_ACLK] =3D &axi_aclk.common.hw, + [CLK_CPU2AON_X2H] =3D &cpu2aon_x2h_clk.common.hw, + [CLK_PERI_AHB_HCLK] =3D &perisys_ahb_hclk.common.hw, + [CLK_CPU2PERI_X2H] =3D &cpu2peri_x2h_clk.common.hw, + [CLK_PERI_APB_PCLK] =3D &perisys_apb_pclk.common.hw, + [CLK_PERI2APB_PCLK] =3D &peri2sys_apb_pclk.common.hw, + [CLK_PERI_APB1_HCLK] =3D &perisys_apb1_hclk.common.hw, + [CLK_PERI_APB2_HCLK] =3D &perisys_apb2_hclk.common.hw, + [CLK_PERI_APB3_HCLK] =3D &perisys_apb3_hclk.common.hw, + [CLK_PERI_APB4_HCLK] =3D &perisys_apb4_hclk.common.hw, + [CLK_OUT1] =3D &out1_clk.common.hw, + [CLK_OUT2] =3D &out2_clk.common.hw, + [CLK_OUT3] =3D &out3_clk.common.hw, + [CLK_OUT4] =3D &out4_clk.common.hw, + [CLK_APB_PCLK] =3D &apb_pclk.common.hw, + [CLK_NPU] =3D &npu_clk.common.hw, + [CLK_NPU_AXI] =3D &npu_axi_clk.common.hw, + [CLK_VI] =3D &vi_clk.common.hw, + [CLK_VI_AHB] =3D &vi_ahb_clk.common.hw, + [CLK_VO_AXI] =3D &vo_axi_clk.common.hw, + [CLK_VP_APB] =3D &vp_apb_clk.common.hw, + [CLK_VP_AXI] =3D &vp_axi_clk.common.hw, + [CLK_CPU2VP] =3D &cpu2vp_clk.common.hw, + [CLK_VENC] =3D &venc_clk.common.hw, + [CLK_DPU0] =3D &dpu0_clk.common.hw, + [CLK_DPU1] =3D &dpu1_clk.common.hw, + [CLK_EMMC_SDIO] =3D &emmc_sdio_clk.common.hw, + [CLK_GMAC1] =3D &gmac1_clk.common.hw, + [CLK_PADCTRL1] =3D &padctrl1_clk.common.hw, + [CLK_DSMART] =3D &dsmart_clk.common.hw, + [CLK_PADCTRL0] =3D &padctrl0_clk.common.hw, + [CLK_GMAC_AXI] =3D &gmac_axi_clk.common.hw, + [CLK_GPIO3] =3D &gpio3_clk.common.hw, + [CLK_GMAC0] =3D &gmac0_clk.common.hw, + [CLK_PWM] =3D &pwm_clk.common.hw, + [CLK_QSPI0] =3D &qspi0_clk.common.hw, + [CLK_QSPI1] =3D &qspi1_clk.common.hw, + [CLK_SPI] =3D &spi_clk.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_UART5_PCLK] =3D &uart5_pclk.common.hw, + [CLK_GPIO0] =3D &gpio0_clk.common.hw, + [CLK_GPIO1] =3D &gpio1_clk.common.hw, + [CLK_GPIO2] =3D &gpio2_clk.common.hw, + [CLK_I2C0] =3D &i2c0_clk.common.hw, + [CLK_I2C1] =3D &i2c1_clk.common.hw, + [CLK_I2C2] =3D &i2c2_clk.common.hw, + [CLK_I2C3] =3D &i2c3_clk.common.hw, + [CLK_I2C4] =3D &i2c4_clk.common.hw, + [CLK_I2C5] =3D &i2c5_clk.common.hw, + [CLK_SPINLOCK] =3D &spinlock_clk.common.hw, + [CLK_DMA] =3D &dma_clk.common.hw, + [CLK_MBOX0] =3D &mbox0_clk.common.hw, + [CLK_MBOX1] =3D &mbox1_clk.common.hw, + [CLK_MBOX2] =3D &mbox2_clk.common.hw, + [CLK_MBOX3] =3D &mbox3_clk.common.hw, + [CLK_WDT0] =3D &wdt0_clk.common.hw, + [CLK_WDT1] =3D &wdt1_clk.common.hw, + [CLK_TIMER0] =3D &timer0_clk.common.hw, + [CLK_TIMER1] =3D &timer1_clk.common.hw, + [CLK_SRAM0] =3D &sram0_clk.common.hw, + [CLK_SRAM1] =3D &sram1_clk.common.hw, + [CLK_SRAM2] =3D &sram2_clk.common.hw, + [CLK_SRAM3] =3D &sram3_clk.common.hw, + [CLK_PLL_GMAC_100M] =3D &gmac_pll_clk_100m.hw, + [CLK_UART_SCLK] =3D &uart_sclk.common.hw, + }, + .num =3D NR_CLKS, +}; + +static const struct regmap_config th1520_clk_regmap_config =3D { + .reg_bits =3D 32, + .val_bits =3D 32, + .reg_stride =3D 4, + .fast_io =3D true, +}; + +static int th1520_clk_probe(struct platform_device *pdev) +{ + struct device *dev =3D &pdev->dev; + struct regmap *map; + void __iomem *regs; + int ret, i; + + regs =3D devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(regs)) + return PTR_ERR(regs); + + map =3D devm_regmap_init_mmio(dev, regs, &th1520_clk_regmap_config); + if (IS_ERR(map)) + return PTR_ERR(map); + + for (i =3D 0; i < ARRAY_SIZE(th1520_clks); i++) + th1520_clks[i]->map =3D map; + + for (i =3D 0; i < th1520_hw_clks.num; i++) { + ret =3D devm_clk_hw_register(dev, th1520_hw_clks.hws[i]); + if (ret) + return ret; + } + + ret =3D devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, + &th1520_hw_clks); + if (ret) + return ret; + + return 0; +} + +static const struct of_device_id th1520_clk_match[] =3D { + { + .compatible =3D "thead,th1520-clk-ap", + }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, th1520_clk_match); + +static struct platform_driver th1520_clk_driver =3D { + .probe =3D th1520_clk_probe, + .driver =3D { + .name =3D "th1520-clk", + .of_match_table =3D th1520_clk_match, + }, +}; +module_platform_driver(th1520_clk_driver); + +MODULE_DESCRIPTION("T-HEAD TH1520 AP Clock driver"); +MODULE_AUTHOR("Yangtao Li "); +MODULE_AUTHOR("Jisheng Zhang "); +MODULE_LICENSE("GPL"); --=20 2.34.1 From nobody Fri Dec 19 12:31:50 2025 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (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 4FBC88820 for ; Sat, 27 Apr 2024 00:10:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714176660; cv=none; b=dXavSQB1gNAHagcj1Hx1TT9uHy3HjJwLzzEExALDn8caetjCx2QF1xNmkCyGH8SLotWnvq6ARMCdr3fAmvH2+q+dLmApU7Nv6Z2zvvfVLNifkFQ9lK7It87X+9ddY6aNhsP8aPHq1rUcW0h70yQzGjFio0N5xA9a8/1B950G9ro= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714176660; c=relaxed/simple; bh=WiDmXN+gE+Oj1XaVtmKA94ORr86HXlbvJPY4osUU3RM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qO4ytKM0irSuXkF23ZKW22b50D75RP5YD3NvpkwxpuTWi1UxnCELErmE6TIVHG8Znq6yexhzHhud2TLZJeDwivqC1Id0EOe5orhbCN0BibpfblyOWN0ajvtkA4CP5bIS8EqKIrTKj8FC1rVTYq9jYWyQQEB+Xd1skBsYXyZzuZE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=tenstorrent.com; spf=pass smtp.mailfrom=tenstorrent.com; dkim=pass (2048-bit key) header.d=tenstorrent.com header.i=@tenstorrent.com header.b=P+O2NaEv; arc=none smtp.client-ip=209.85.210.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=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="P+O2NaEv" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-6ed20fb620fso2511548b3a.2 for ; Fri, 26 Apr 2024 17:10:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tenstorrent.com; s=google; t=1714176658; x=1714781458; 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=F5ki95UEfr2z0VC3x180o/+jUI7myGNjHePyoD0A2y8=; b=P+O2NaEvucAdautkgsxIo6Jo5RBzeU4JcwmPAuYK1x5NrqZSbeoFzTxSKEn4/DkVws EJ95cwKtO/dMlSkZvpeQLhb71Wne+r5MA7fcTQ/4QnClEBxYfKkE6wRA7JHtFwu7nqlX qgLJoRY4emxSwOe2J8M3WuaKD1+RT7XLE+7TGupMUUqVbmBOHtBvpPKn5AZCQ5eC9QIS 85TKCygJX76qtxw689rMZn+q2O3yQPmBJ7ZI/uvChqlxz2gPy5V1jt4aAnIarBaxKuOp 568vvZ1TlWmSdtpxH/twA//afvRlg6kg0N69cRCXMOMZjFU/RDmatlH++G5EL9ce46E3 71fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714176658; x=1714781458; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F5ki95UEfr2z0VC3x180o/+jUI7myGNjHePyoD0A2y8=; b=SFSIJYsvzbeYeHhTEW+DyzrHD7y0UsRHS5coYrjS3fAj4XIy0McGgktExQLigkavML nBqS3e5VeL99qrD47nAz7nsLDTTymz8xc4toKNiEzN6G4ydUt+AOyC/+Dt7cuCV5tjsB W8uZyCqSiBo1oyrfjwFDzlhF4xjZLtaD0uePFaYQTiX5UCoG0PDHz0xQ/5xNgVrMfOkJ knTFtA64BI+u5USOdnDbo4CQc7Cegy2GqlgOl+9bdzy9HeUfjdye/4eKf3AUFZ9SSdSJ 6I8Cbut/ImYA6rClTlWJdRDTa8HA3k9/eU2vY20MKmoUBgVQNDOPbZLfDGWozT6mxzDC 1JNw== X-Forwarded-Encrypted: i=1; AJvYcCUosX6vEBNAY/++KJLV1xsexTyE7JvM2bY0zODG4Wq1uREExFWTNl/tyeCAYdp+d7wlliCnrfbW7VaEzwgqW3Y5prirdNpPXtLB3UfK X-Gm-Message-State: AOJu0YxUYM94Ik4ntA62zO2jjfj1cbcMcpyKd0tVoUEtl2S/B4s/DDex H4KZUg318TH+pexQ3MPr/k5M6GqnNln+QUlXeKNDoWz7c7nSrdXk1xrG9ceSnPg= X-Google-Smtp-Source: AGHT+IFAgfIAI3/KuUTKpVzyvA9o5IQ/hm2YlS9fAPFKU/vAHWC7oo96mJ9J807N5OowZHBwaZ13Dw== X-Received: by 2002:a05:6a20:918e:b0:1ac:6762:e62e with SMTP id v14-20020a056a20918e00b001ac6762e62emr5665000pzd.30.1714176658577; Fri, 26 Apr 2024 17:10:58 -0700 (PDT) Received: from [127.0.1.1] ([2601:1c2:1802:170:3569:7ce4:94b8:1691]) by smtp.gmail.com with ESMTPSA id w1-20020a6556c1000000b005f3d54c0a57sm6061883pgs.49.2024.04.26.17.10.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 17:10:58 -0700 (PDT) From: Drew Fustini Date: Fri, 26 Apr 2024 17:10:36 -0700 Subject: [PATCH RFC v2 3/4] riscv: dts: thead: Add TH1520 AP_SUBSYS clock controller 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: <20240426-th1520-clk-v2-v2-3-96b829e6fcee@tenstorrent.com> References: <20240426-th1520-clk-v2-v2-0-96b829e6fcee@tenstorrent.com> In-Reply-To: <20240426-th1520-clk-v2-v2-0-96b829e6fcee@tenstorrent.com> To: Jisheng Zhang , Guo Ren , Fu Wei , Yangtao Li , Thomas Bonnefille , Emil Renner Berthing , Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Drew Fustini , Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: linux-riscv@lists.infradead.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1714176654; l=1160; i=dfustini@tenstorrent.com; s=20230430; h=from:subject:message-id; bh=WiDmXN+gE+Oj1XaVtmKA94ORr86HXlbvJPY4osUU3RM=; b=z+fbT5Gr7t67Rr88wnhdlVKhPZX1zS0AMbe6NxbQ9g3D2bhGOs+5SSpgPoUawGn7P+ESJzWYz lpFXBf7p6AYCVdX2h0+d+CLQ+0v9Pzv0a2iF2lJ15sroJqydTVVDZ+6 X-Developer-Key: i=dfustini@tenstorrent.com; a=ed25519; pk=p3GKE9XFmjhwAayAHG4U108yag7V8xQVd4zJLdW0g7g= Add node for the AP_SUBSYS clock controller on the T-Head TH1520 SoC. Link: https://openbeagle.org/beaglev-ahead/beaglev-ahead/-/blob/main/docs/T= H1520%20System%20User%20Manual.pdf Signed-off-by: Drew Fustini Tested-by: Thomas Bonnefille --- arch/riscv/boot/dts/thead/th1520.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/th= ead/th1520.dtsi index 8b915e206f3a..6285cdf91bd6 100644 --- a/arch/riscv/boot/dts/thead/th1520.dtsi +++ b/arch/riscv/boot/dts/thead/th1520.dtsi @@ -5,6 +5,7 @@ */ =20 #include +#include =20 / { compatible =3D "thead,th1520"; @@ -161,6 +162,14 @@ soc { dma-noncoherent; ranges; =20 + clk: clock-controller@ffef010000 { + compatible =3D "thead,th1520-clk-ap"; + reg =3D <0xff 0xef010000 0x0 0x1000>; + clocks =3D <&osc>; + clock-names =3D "osc"; + #clock-cells =3D <1>; + }; + plic: interrupt-controller@ffd8000000 { compatible =3D "thead,th1520-plic", "thead,c900-plic"; reg =3D <0xff 0xd8000000 0x0 0x01000000>; --=20 2.34.1 From nobody Fri Dec 19 12:31:50 2025 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (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 055218F6B for ; Sat, 27 Apr 2024 00:10:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714176661; cv=none; b=ACXkA9spDkoMWPDPlJ57WPKXaEY/Dz2a5Kw+Qju9G47FQvUck/qE7IlSye7KHgTrZ/iyIvY+H+TBAmmqMZd8JbumcxE9joPcCGCbjy8zn3bP45Ikc7FDD7Enqinf7GdCyvAECqnMzema1W8ldBYkVdOvwAuE8eYGpkvg07R4aHs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714176661; c=relaxed/simple; bh=Tkyi4QZD3iXRNC9I3Th5GPUlpVYoVqpI8o+66sXr35M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lwzQR76REAEwmG3c7tUNaV69tFUrFFxybCRxnE3l+GhNGP8LwI88z5a33keAYMrbU+uEoSrGMpPQxCCaVqAvSrmqsDg9XhMNIeJbpU2osfISjbRaq1k0MMqdwwJ61GCDvTXs7m77RmqpAxaXLgBXnGZ9XADZaRAlodbLCNRIRW0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=tenstorrent.com; spf=pass smtp.mailfrom=tenstorrent.com; dkim=pass (2048-bit key) header.d=tenstorrent.com header.i=@tenstorrent.com header.b=ZEaWsCQO; arc=none smtp.client-ip=209.85.210.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=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="ZEaWsCQO" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-6ecff9df447so2725297b3a.1 for ; Fri, 26 Apr 2024 17:10:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tenstorrent.com; s=google; t=1714176659; x=1714781459; 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=u/8O6an2WdHxxonYSgEiYeduIeqZHNZdg71uXcAFpLM=; b=ZEaWsCQOKbQrHKEahRxNjkAw4POlRtwAg5WzveZXle1mzvVjAFFx8ypeWEnULdLPkK vMPZRgg3R3eDWlf58X2wWy1BgMfAHgosmBq7/FPse8tB9NOFGPFxIHvgckdRQWl/iEk4 9chfebcre6ViKpJ9ZTmZsEoHjijNkoDMLiXs9ZSQpUP53dpZY+UEPnRexqxlPPUyxDYC dwtkLdN9glE4s95b3M0Z8XhPHFSRW/8snwVQaZF5rkH9Gv9RpNSY4DZREWi46UQ0diTt uzgyL38cSiCca3Mprw0qule2MyvGmp7GJUJ6906Vl8HNMDe/PNHm/wIpjWrIfKzTXLa5 dqeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714176659; x=1714781459; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u/8O6an2WdHxxonYSgEiYeduIeqZHNZdg71uXcAFpLM=; b=X7VNPfTVQYkFyXK4S35Ry6PUKdCB7FzUzmQlF/2bkxOjqaZWKZkxQclxO3aE9EGYfr U5vQra9iy1eyGTDBp7EYrgQTGFtHRSiAiWCXkxcQT4MGNtx4yJjiVIQhKF4+/tM7kr9m E8Z544TxnciBPTkl91FZZ+5alfDQYiLMB9WYPYv5XUWRFgrTEpNQLBUj0Kov4TT7ApnP SXc9a5fNXFYngrMw0nzj3IlBFe2/k2EI/mntK/Nz4eeJkzmPYJZGWpb3hSKWCCI/yspO cpMpU6r8t9qG8rzH4HoeqnGkOIS/EEaknHPGttqsldiutdA/+fu2n8q84UaSLqhG3VWs cnxA== X-Forwarded-Encrypted: i=1; AJvYcCU5zz8XX2/0HjHqrmWk2iOWEWTU1juLfLz3E5BcqopnZ6t1WJr4WVHTrr6HPQtqWNbEW/Kdf7LsjlYrO38rsksYRsC7lYoNnGsbbZi7 X-Gm-Message-State: AOJu0YxFKSgkNGf0mi8XPqyQf2AaaHRufLx7knM/NRibL6QuObLIRAZh d6JflTtkzsRP+kHAagFW5HtZQ1N+qYVrXRUw9CFPLXJ7KL2Tc2znWQ1xjQO/gqsSnjVST2UhAMz 4Wgk= X-Google-Smtp-Source: AGHT+IHYGANP1t640rQDF4TNy0DIxIquUVdYZoD1tRH1yjH88XxV9oq8sxkuJD55TgcVLJd3G3z2gw== X-Received: by 2002:a05:6a00:174a:b0:6ec:fdcc:40b9 with SMTP id j10-20020a056a00174a00b006ecfdcc40b9mr6286127pfc.9.1714176659410; Fri, 26 Apr 2024 17:10:59 -0700 (PDT) Received: from [127.0.1.1] ([2601:1c2:1802:170:3569:7ce4:94b8:1691]) by smtp.gmail.com with ESMTPSA id w1-20020a6556c1000000b005f3d54c0a57sm6061883pgs.49.2024.04.26.17.10.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 17:10:59 -0700 (PDT) From: Drew Fustini Date: Fri, 26 Apr 2024 17:10:37 -0700 Subject: [PATCH RFC v2 4/4] riscv: dts: thead: Add clock to TH1520 mmc controllers 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: <20240426-th1520-clk-v2-v2-4-96b829e6fcee@tenstorrent.com> References: <20240426-th1520-clk-v2-v2-0-96b829e6fcee@tenstorrent.com> In-Reply-To: <20240426-th1520-clk-v2-v2-0-96b829e6fcee@tenstorrent.com> To: Jisheng Zhang , Guo Ren , Fu Wei , Yangtao Li , Thomas Bonnefille , Emil Renner Berthing , Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Drew Fustini , Paul Walmsley , Palmer Dabbelt , Albert Ou Cc: linux-riscv@lists.infradead.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1714176654; l=1420; i=dfustini@tenstorrent.com; s=20230430; h=from:subject:message-id; bh=Tkyi4QZD3iXRNC9I3Th5GPUlpVYoVqpI8o+66sXr35M=; b=i3zE1I6IyMOXFj1bKYUcSwl0Q+FnHv6uXONEvzmZvhfqQFzAPv6ylEPDFIVtUnS30Bx/yo+p2 EZ3wEbt1Ps4A+ZnwPmEdb/PCw8a64vl7uB541tl7Q8wYln+VeouGe4d X-Developer-Key: i=dfustini@tenstorrent.com; a=ed25519; pk=p3GKE9XFmjhwAayAHG4U108yag7V8xQVd4zJLdW0g7g= Change the clock property in the T-Head TH1520 mmc controller nodes to a real clock provided by the AP_SUBSYS clock driver. Signed-off-by: Drew Fustini Tested-by: Thomas Bonnefille --- arch/riscv/boot/dts/thead/th1520.dtsi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/th= ead/th1520.dtsi index 6285cdf91bd6..a6f51ec9fb55 100644 --- a/arch/riscv/boot/dts/thead/th1520.dtsi +++ b/arch/riscv/boot/dts/thead/th1520.dtsi @@ -324,7 +324,7 @@ emmc: mmc@ffe7080000 { compatible =3D "thead,th1520-dwcmshc"; reg =3D <0xff 0xe7080000 0x0 0x10000>; interrupts =3D <62 IRQ_TYPE_LEVEL_HIGH>; - clocks =3D <&sdhci_clk>; + clocks =3D <&clk CLK_EMMC_SDIO>; clock-names =3D "core"; status =3D "disabled"; }; @@ -333,7 +333,7 @@ sdio0: mmc@ffe7090000 { compatible =3D "thead,th1520-dwcmshc"; reg =3D <0xff 0xe7090000 0x0 0x10000>; interrupts =3D <64 IRQ_TYPE_LEVEL_HIGH>; - clocks =3D <&sdhci_clk>; + clocks =3D <&clk CLK_EMMC_SDIO>; clock-names =3D "core"; status =3D "disabled"; }; @@ -342,7 +342,7 @@ sdio1: mmc@ffe70a0000 { compatible =3D "thead,th1520-dwcmshc"; reg =3D <0xff 0xe70a0000 0x0 0x10000>; interrupts =3D <71 IRQ_TYPE_LEVEL_HIGH>; - clocks =3D <&sdhci_clk>; + clocks =3D <&clk CLK_EMMC_SDIO>; clock-names =3D "core"; status =3D "disabled"; }; --=20 2.34.1