Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp252236lqp; Tue, 11 Jun 2024 23:42:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX7MWtToJEbXIajfrXSRWsap+tN5hRtndLwcY0aX2iUVGSWjWYeWUCr/Y7ugMIBCtyve1F84ufyuRHtMVVLdeMzcRHxMHS1H4JiOWbDlg== X-Google-Smtp-Source: AGHT+IFgcFrJ5EAyjA/qSV9/wAR5ZwjlBOTe27Lsfz3a9HrCd+mMRRPlxZSalbr4GtE3opUa7dnE X-Received: by 2002:a50:ab4b:0:b0:57c:7fc1:5d5d with SMTP id 4fb4d7f45d1cf-57caaabb8abmr501258a12.34.1718174566487; Tue, 11 Jun 2024 23:42:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718174566; cv=pass; d=google.com; s=arc-20160816; b=b6SW3r4eyOwrwhcMal4aydNyCV5bOshNyM1JNOrIj0GOCh3cLHvxHNvFTizvg13zRn gE9pPATbYWl0Uy2uuGj1SXUmBJSP/FwiKJ0N56LULciM/Mb/7a/ALijNMwtMm0GoES7h 779HGxKG61Ohl8Fg9Kl/wvxXNtU0wWMXZpoUJlH1hx6XlVfKCyH9A1UJZme5Jc9XQ8Zn JjK47TUxtQUHuPF7JzDTUmyIgr82YAoytfj2ZmQklu3UH3g3f/aKGxCOu9xnh1mqzfMA ZbDsJ7M/Z+gFyfgJtcnlRXWElvVoKtN+gL/+akyLq9MmTr/KiwnVkWFM6SPlw6OXlEzd ygVA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=LwLfKa604x6+ntZpUj1/S3s+1WU9WKdpF+2LbVRyIgo=; fh=G4Y7073zkpIeVjs/fT9SL5LP3veV8fqwHBH86bYqeAQ=; b=QjxQq6vWTePUUjEiF+RB3aS6GgrvIkg6c8codtBO1nCem4lcx+lav0FqrQcfbaJgyJ YRW4D1NDgFLwmuJjQdHxGKqREuz23VTc078ungNIT322Mxyu0BD40Awz+q+8zuFB6orG W2AmnuVPwX9JmvCVpDWGGWNKcveew3f7CkdRQ2Ju8X097SfKvs2lwb0S1AqVAl4iEc7n JaZCkpmN5I39Pem8tF5L05oK9DQIJrL6UGqstKyKJCS+ajdDriKLvlVSuN2rDaVKO0wU eh39UbvSiaoh7GenWqg3o8v3TTOqfi0Q+7xyryEQj8EmjVTHQCPl63eGb8dYNkBYoa5g TzEg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-210994-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210994-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57c81fc76d2si2879832a12.178.2024.06.11.23.42.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 23:42:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-210994-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-210994-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210994-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 333DE1F24DD7 for ; Wed, 12 Jun 2024 06:42:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3558216B736; Wed, 12 Jun 2024 06:42:38 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A573F13BC05; Wed, 12 Jun 2024 06:42:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718174557; cv=none; b=KyH4gzljmhKrQFaR7EfpUXL6DZo+A8fodsN10ReLkFMAhSfbwHGFf7aYycT/Rh00rKESHjrw9tigx2a9pPMLSjO50aKpjzySigCLQLQjdWPodkf7xNOffwFOEcS5uaD2VIeQKWaS1LEG+9C5imO05fCTKOyblqK0LoCHCMKjrT4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718174557; c=relaxed/simple; bh=XVpNvv7dutfr0NAL/LUAO2hwYx4PCPDqIKIqQ42xaXM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cyL03mMu56dUwHt3vGwFiXlXREo/ZFuE4nCpfWXqkLPHVRqQ4JVFTPTX3EPzHnukdEtz6bG3BOOZ9dPITUmEPDc6slBH/Pns+v24N5zTmZ7q4loxkRbaFOwJNpSGwCd3ARsbKUXsYdpeQ9mKmfPrV6dqKzLOlEEsauV1bfYR024= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8747C32786; Wed, 12 Jun 2024 06:42:34 +0000 (UTC) From: Huacai Chen To: "Rafael J . Wysocki" , Viresh Kumar , Huacai Chen Cc: loongarch@lists.linux.dev, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Xuerui Wang , Jiaxun Yang , Huacai Chen , Binbin Zhou Subject: [PATCH 1/2] LoongArch: Add architectural preparation for CPUFreq Date: Wed, 12 Jun 2024 14:42:04 +0800 Message-ID: <20240612064205.2041548-2-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240612064205.2041548-1-chenhuacai@loongson.cn> References: <20240612064205.2041548-1-chenhuacai@loongson.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add architectural preparation for CPUFreq driver, including: Kconfig, register definition and platform device registration. Some of LoongArch processors support DVFS, their IOCSR.FEATURES has IOCSRF_FREQSCALE set. And they has a micro-core in the package called SMC (System Management Controller) to scale frequency, voltage, etc. Signed-off-by: Binbin Zhou Signed-off-by: Huacai Chen --- arch/loongarch/Kconfig | 1 + arch/loongarch/include/asm/loongarch.h | 3 +++ arch/loongarch/power/platform.c | 15 +++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig index e38139c576ee..dffa9c454123 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -696,6 +696,7 @@ config ARCH_HIBERNATION_POSSIBLE source "kernel/power/Kconfig" source "drivers/acpi/Kconfig" +source "drivers/cpufreq/Kconfig" endmenu diff --git a/arch/loongarch/include/asm/loongarch.h b/arch/loongarch/include/asm/loongarch.h index eb09adda54b7..7d89b2ecf2c2 100644 --- a/arch/loongarch/include/asm/loongarch.h +++ b/arch/loongarch/include/asm/loongarch.h @@ -1053,11 +1053,14 @@ #define LOONGARCH_IOCSR_NODECNT 0x408 #define LOONGARCH_IOCSR_MISC_FUNC 0x420 +#define IOCSR_MISC_FUNC_SOFT_INT BIT_ULL(10) #define IOCSR_MISC_FUNC_TIMER_RESET BIT_ULL(21) #define IOCSR_MISC_FUNC_EXT_IOI_EN BIT_ULL(48) #define LOONGARCH_IOCSR_CPUTEMP 0x428 +#define LOONGARCH_IOCSR_SMCMBX 0x51c + /* PerCore CSR, only accessible by local cores */ #define LOONGARCH_IOCSR_IPI_STATUS 0x1000 #define LOONGARCH_IOCSR_IPI_EN 0x1004 diff --git a/arch/loongarch/power/platform.c b/arch/loongarch/power/platform.c index 3ea8e07aa225..a19353f7d1b0 100644 --- a/arch/loongarch/power/platform.c +++ b/arch/loongarch/power/platform.c @@ -34,6 +34,21 @@ void enable_pci_wakeup(void) acpi_write_bit_register(ACPI_BITREG_PCIEXP_WAKE_DISABLE, 0); } +static struct platform_device loongson3_cpufreq_device = { + .name = "loongson3_cpufreq", + .id = -1, +}; + +static int __init loongson_cpufreq_init(void) +{ + if (!cpu_has_scalefreq) + return -ENODEV; + + return platform_device_register(&loongson3_cpufreq_device); +} + +arch_initcall(loongson_cpufreq_init); + static int __init loongson3_acpi_suspend_init(void) { #ifdef CONFIG_ACPI -- 2.43.0