From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.1 X-Yandex-Fwd: 2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1653064180; bh=OOydkaPE5IEpUQiNzbTcOrOHa+QSsD2of/T0aHoc+JI=; h=Reply-To:In-Reply-To:References:Date:Subject:Cc:To:From: Message-Id; b=RIN3gEMHJ8/gRyxsoEQjGUViPTNv16Y5WPz3otFMdhxLylroVonTVe+4MUi8TtBSF iKZkhlP7IymIPsM8xLnf7TsSG7TL0TnZ82ZcoU0iqu42Hj/a38WZNGRcY0cNl9fR/w GniSxUea39MmgrAnfU7gwBNJaNi3NdmP82AbfLso= Authentication-Results: sas1-2c02ca35cfae.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru From: asheplyakov@yandex.ru To: devel@lists.altlinux.org Date: Fri, 20 May 2022 20:28:20 +0400 Message-Id: <20220520162849.1554351-7-asheplyakov@yandex.ru> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220520162849.1554351-1-asheplyakov@yandex.ru> References: <20220520162849.1554351-1-asheplyakov@yandex.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Cc: Vitaly Chikunov , Alexey Sheplyakov , Igor Chudov , Evgeny Sinelnikov Subject: [devel] [PATCH 06/35] hwmon: bt1-pvt: define pvt_readl/pvt_writel for Baikal-M SoC X-BeenThere: devel@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: ALT Linux Team development discussions List-Id: ALT Linux Team development discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 May 2022 16:29:45 -0000 Archived-At: List-Archive: List-Post: From: Alexey Sheplyakov On Baikal-M Linux has to call into firmware (ARM-TF) to access PVT registers. Signed-off-by: Alexey Sheplyakov X-feature-Baikal-M --- drivers/hwmon/bt1-pvt.c | 23 +++++++++++++++++++++++ drivers/hwmon/bt1-pvt.h | 8 ++++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/hwmon/bt1-pvt.c b/drivers/hwmon/bt1-pvt.c index c05fe8df0839..2f2a222bd136 100644 --- a/drivers/hwmon/bt1-pvt.c +++ b/drivers/hwmon/bt1-pvt.c @@ -29,6 +29,9 @@ #include #include #include +#ifdef CONFIG_ARM64 +#include +#endif #include "bt1-pvt.h" @@ -138,6 +141,7 @@ static long pvt_calc_poly(const struct pvt_poly *poly, long data) return ret / poly->total_divider; } +#ifdef BT1_PVT_DIRECT_REG_ACCESS static inline u32 pvt_readl(struct pvt_hwmon const *pvt, int reg) { return readl(pvt->regs + reg); } @@ -149,6 +153,25 @@ static inline u32 pvt_readl_relaxed(struct pvt_hwmon const *pvt, int reg) { static inline void pvt_writel(u32 data, struct pvt_hwmon const *pvt, int reg) { writel(data, pvt->regs + reg); } +#else +static inline u32 pvt_readl(struct pvt_hwmon const *pvt, int reg) { + struct arm_smccc_res res; + arm_smccc_smc(BAIKAL_SMC_PVT_ID, PVT_READ, pvt->pvt_id, reg, + 0, 0, 0, 0, &res); + return res.a0; +} + +static inline u32 pvt_readl_relaxed(struct pvt_hwmon const *pvt, int reg) { + return pvt_readl(pvt, reg); +} + +static inline void pvt_writel(u32 data, struct pvt_hwmon const *pvt, int reg) { + struct arm_smccc_res res; + arm_smccc_smc(BAIKAL_SMC_PVT_ID, PVT_WRITE, pvt->pvt_id, reg, + data, 0, 0, 0, &res); +} +#endif + static inline u32 pvt_update(struct pvt_hwmon *pvt, int reg, u32 mask, u32 data) { u32 old; diff --git a/drivers/hwmon/bt1-pvt.h b/drivers/hwmon/bt1-pvt.h index 93b8dd5e7c94..0cea95b01c13 100644 --- a/drivers/hwmon/bt1-pvt.h +++ b/drivers/hwmon/bt1-pvt.h @@ -101,6 +101,13 @@ # define PVT_TOUT_DEF 0 #endif +#define BAIKAL_SMC_PVT_ID 0x82000001 +#define PVT_READ 0 +#define PVT_WRITE 1 +#ifndef CONFIG_ARM64 +#define BT1_PVT_DIRECT_REG_ACCESS +#endif + /* * enum pvt_sensor_type - Baikal-T1 PVT sensor types (correspond to each PVT * sampling mode) @@ -217,6 +224,7 @@ struct pvt_hwmon { enum pvt_sensor_type sensor; struct pvt_cache cache[PVT_SENSORS_NUM]; ktime_t timeout; + int pvt_id; }; /* -- 2.32.0