From patchwork Tue Sep 26 12:28:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 727162 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 D65FA27725 for ; Tue, 26 Sep 2023 12:28:17 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 03C4D10E; Tue, 26 Sep 2023 05:28:16 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EEE4ADA7; Tue, 26 Sep 2023 05:28:53 -0700 (PDT) Received: from e103737-lin.cambridge.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A69B53F6C4; Tue, 26 Sep 2023 05:28:14 -0700 (PDT) From: Sudeep Holla Date: Tue, 26 Sep 2023 13:28:00 +0100 Subject: [PATCH 1/3] ACPI: PCC: Add PCC shared memory region command and status bitfields Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20230926-pcc_defines-v1-1-0f925a1658fd@arm.com> References: <20230926-pcc_defines-v1-0-0f925a1658fd@arm.com> In-Reply-To: <20230926-pcc_defines-v1-0-0f925a1658fd@arm.com> To: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-acpi@vger.kernel.org Cc: Sudeep Holla , "Rafael J. Wysocki" , Andi Shyti , Jean Delvare , Guenter Roeck X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1291; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=NVqjx3KgceHBDTtKRT2jKbwqByxepAzV4t81BveYQ5M=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlEs5cZoCKp1fj4orfty+KxtexocPaVbXd7vjYf uLKxbZc9vGJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZRLOXAAKCRAAQbq8MX7i mLPaD/4vBWFKN8LW/fljCcv/jfrVigPDq5yyR4l6t/r19KeSBzENurRpQFPTxwg+oa88Wvnyu6s UO/+1IdUR4MotZ48Sb2rZUJKqPQP4iUGGPlC+q9EVW5TrTFpBBI+kNMxfp6mqSj6xCvKo+oROpE IPc3DJEUogDgTu1z70K7Ll5C1mxzmhJrZMEo/f5WGxXUETEfpb93rhUWcHSwC9flEc5a6gETG36 1fZ/rQHy2UVdLaNwpPQDeCpSl4CXcxyPk8FmKmlV/2bm2ZECgd5JgjuREZ56NA8mEcQN2VA4ODL pDYMQAuSTWXnAK0f3dMdMsXDoE1SzwcpAg5nlouZPEjg6790k2WMpK/oAPlqQA6X2OA+PLWnztu n+euqI/RQhCFohzKjvrW5/X5jMXCiVDgG7+wfoSeuWURqkCYSPD9cPQza0OP2FP7mHE9/lJv4I5 0RKBAHZpM2kjOgUcyziNGhnNx6pci8rVZXh8BytvUzpo2treIB/6vabmJiwWIjGyTa25IWibQhj SuhHVcAPVtWsEfte13t3DoLLphVQxCddRyrJOgrB5nXGTDJJpIgJZUPZL6JSWlW9gDWm9uVeW08 zJSdNwCG+8lwVfWL8L1nBTNA89dab4dcVaZmX4LoHvqRWud9C6Ss17aygeNx0zMdXXaw/mazg2N y+70fICPW4QTJnw== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Define the common macros to use when referring to various bitfields in the PCC generic communications channel command and status fields. Currently different drivers that need to use these bitfields have defined these locally. This common macro is intended to consolidate and replace those. Cc: Rafael J. Wysocki Signed-off-by: Sudeep Holla --- include/acpi/pcc.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/acpi/pcc.h b/include/acpi/pcc.h index 73e806fe7ce7..66d9934c2ee4 100644 --- a/include/acpi/pcc.h +++ b/include/acpi/pcc.h @@ -18,7 +18,18 @@ struct pcc_mbox_chan { u16 min_turnaround_time; }; +/* Generic Communications Channel Shared Memory Region */ +#define PCC_SIGNATURE 0x50424300 +/* Generic Communications Channel Command Field */ +#define PCC_CMD_GENERATE_DB_INTR BIT(15) +/* Generic Communications Channel Status Field */ +#define PCC_STATUS_CMD_COMPLETE BIT(0) +#define PCC_STATUS_SCI_DOORBELL BIT(1) +#define PCC_STATUS_ERROR BIT(2) +#define PCC_STATUS_PLATFORM_NOTIFY BIT(3) + #define MAX_PCC_SUBSPACES 256 + #ifdef CONFIG_PCC extern struct pcc_mbox_chan * pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id); From patchwork Tue Sep 26 12:28:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 726457 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 1112A846A for ; Tue, 26 Sep 2023 12:28:18 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 94898FB; Tue, 26 Sep 2023 05:28:17 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4541DFEC; Tue, 26 Sep 2023 05:28:55 -0700 (PDT) Received: from e103737-lin.cambridge.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F0D6F3F6C4; Tue, 26 Sep 2023 05:28:15 -0700 (PDT) From: Sudeep Holla Date: Tue, 26 Sep 2023 13:28:01 +0100 Subject: [PATCH 2/3] i2c: xgene-slimpro: Migrate to use generic PCC shmem related macros Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20230926-pcc_defines-v1-2-0f925a1658fd@arm.com> References: <20230926-pcc_defines-v1-0-0f925a1658fd@arm.com> In-Reply-To: <20230926-pcc_defines-v1-0-0f925a1658fd@arm.com> To: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-acpi@vger.kernel.org Cc: Sudeep Holla , "Rafael J. Wysocki" , Andi Shyti , Jean Delvare , Guenter Roeck X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2106; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=+8XMvgcBZDMKcEA3RRExPbyScwOjYNRYC/UYX8cjwNs=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlEs5cfOigpBTgwA3trZcDjDYUNOuJ51IVXqpow VpCpVfAt5iJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZRLOXAAKCRAAQbq8MX7i mLYREADFHDxsCs80lSs+CHiNM7u1QjKyEiZvh1oO21L58p2dSnEpXO5KTn/8gaHrGgNXRITYAR/ AQl7bUxBB1DbBHNfXXBJYTWDt0lm/isxKeLWjf78m5iGGhzzy4H8Plica2fY9nb9hAJFd2ihrXy mFFOwVbBHRspyG5NC6VOBC34Bm6GW66uI4QdlojLvgI9TICajc/+cx2IsGxhj+/9/3IA38YppVV qr5RZd1Am7bfqnASPL8g5w/xzJ18+AZy/vHZA0SfSl+ydrCyU6cPrk464cpdQ8CGIcKD4auc3Su Wvi4Dkxs2FyMfqhXEFty5ZoSFo8DkJkdKCu8+9m0gQfKlgMDoOlhguPRf/Oj6rRdIGBrt2NVqwD uGsvB/80NInJDTHInikJnfdGA32oj/dBTNjsGcvZpQz3c1W2lRaELloIi9xuO2hkX/SMvlANu7B R6Ni1YEY9efER9h0MEJzO5e3B/ScoxkFgo7G0hC0qhDqqA3YuhgZdNTlQGwj6dc1PUeNqS5Io1F 8aYExSp/b9tWh5OjR4fTXcedw3+RbaJrlYlF0K/VNxYvMhizfr5D395YbL7NRbDZSxMWxXFG57B xI9Bp6YcVTi4qJbAeDXIUQx+U20XmCihVcgBaFtO+tDVA8pDJo0LwEM7tw/qguBrFY9KpxQYQ/M rMfLqsD9tRrCtug== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Use the newly defined common and generic PCC shared memory region related macros in this driver to replace the locally defined ones. Cc: Andi Shyti Signed-off-by: Sudeep Holla Reviewed-by: Andi Shyti --- drivers/i2c/busses/i2c-xgene-slimpro.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/i2c/busses/i2c-xgene-slimpro.c b/drivers/i2c/busses/i2c-xgene-slimpro.c index fbc1ffbd2fa7..658396c9eeab 100644 --- a/drivers/i2c/busses/i2c-xgene-slimpro.c +++ b/drivers/i2c/busses/i2c-xgene-slimpro.c @@ -91,14 +91,6 @@ #define SLIMPRO_IIC_MSG_DWORD_COUNT 3 -/* PCC related defines */ -#define PCC_SIGNATURE 0x50424300 -#define PCC_STS_CMD_COMPLETE BIT(0) -#define PCC_STS_SCI_DOORBELL BIT(1) -#define PCC_STS_ERR BIT(2) -#define PCC_STS_PLAT_NOTIFY BIT(3) -#define PCC_CMD_GENERATE_DB_INT BIT(15) - struct slimpro_i2c_dev { struct i2c_adapter adapter; struct device *dev; @@ -160,11 +152,11 @@ static void slimpro_i2c_pcc_rx_cb(struct mbox_client *cl, void *msg) /* Check if platform sends interrupt */ if (!xgene_word_tst_and_clr(&generic_comm_base->status, - PCC_STS_SCI_DOORBELL)) + PCC_STATUS_SCI_DOORBELL)) return; if (xgene_word_tst_and_clr(&generic_comm_base->status, - PCC_STS_CMD_COMPLETE)) { + PCC_STATUS_CMD_COMPLETE)) { msg = generic_comm_base + 1; /* Response message msg[1] contains the return value. */ @@ -186,10 +178,10 @@ static void slimpro_i2c_pcc_tx_prepare(struct slimpro_i2c_dev *ctx, u32 *msg) cpu_to_le32(PCC_SIGNATURE | ctx->mbox_idx)); WRITE_ONCE(generic_comm_base->command, - cpu_to_le16(SLIMPRO_MSG_TYPE(msg[0]) | PCC_CMD_GENERATE_DB_INT)); + cpu_to_le16(SLIMPRO_MSG_TYPE(msg[0]) | PCC_CMD_GENERATE_DB_INTR)); status = le16_to_cpu(READ_ONCE(generic_comm_base->status)); - status &= ~PCC_STS_CMD_COMPLETE; + status &= ~PCC_STATUS_CMD_COMPLETE; WRITE_ONCE(generic_comm_base->status, cpu_to_le16(status)); /* Copy the message to the PCC comm space */ From patchwork Tue Sep 26 12:28:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 727161 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 14E1927725 for ; Tue, 26 Sep 2023 12:28:20 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9BD93FC; Tue, 26 Sep 2023 05:28:18 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8F7841480; Tue, 26 Sep 2023 05:28:56 -0700 (PDT) Received: from e103737-lin.cambridge.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 475BB3F6C4; Tue, 26 Sep 2023 05:28:17 -0700 (PDT) From: Sudeep Holla Date: Tue, 26 Sep 2023 13:28:02 +0100 Subject: [PATCH 3/3] hwmon: (xgene) Migrate to use generic PCC shmem related macros Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20230926-pcc_defines-v1-3-0f925a1658fd@arm.com> References: <20230926-pcc_defines-v1-0-0f925a1658fd@arm.com> In-Reply-To: <20230926-pcc_defines-v1-0-0f925a1658fd@arm.com> To: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-acpi@vger.kernel.org Cc: Sudeep Holla , "Rafael J. Wysocki" , Andi Shyti , Jean Delvare , Guenter Roeck X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2535; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=xAB9DO9/WuBfrCyxIgct5Wml2oQRa0x+hPVPHrXNjoA=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlEs5dgRCkg3Q8R+TXzB+/wrKszSybk6z9171cI 3pqISWetFmJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZRLOXQAKCRAAQbq8MX7i mLEGEACl2JMbMOB+9OV8WlvKM7hyGqeLYE6pFW9p0ZqGXyCXsWZaZiAtXXFKjl9/l7Yi5oeoIrE dOK4RA1guAGaulOWlUZRn3E1VfZLwtUTztToPY6AP7sqXUbIouIRHajm6e6AEKs1PQlMIH6TSSQ HJa24nPd863GDeAgwSTO6Zc2vxv4A6ea+L40qP1U13f1xlj0vEaarNJ1qMfVo+T+xh2NyxpSlOB ptpiVoGj4JCBAFfm5bXKwegkaN/sXGe6G8vrJq9mpaCmtJ6eeAzimJIuufvmanNUGi8q/CMwKOJ avyx9YuhtVdlNhKN0eR5Yzs9blKq9nxQU2tGHKObR/2cUG41MZ4j3aJ4x5p9K0+91bn0G5VzdG9 SzoZ2ehCblxfvjQP+15G1HLGfzfN2LBiyzi49cC48k72DxdLf1kxg2QOGfhCSuL8tb/eqeF6NAw m/aiGnxi7tVr53hP9aZ3XFUzpnuiz2r4wJs9n+kxV7srdj+CTa0U9LWKicfw2oQsjJYtnvyBqtF Pp+GxV2/2412qdNkjkAmnwOlU7aUW7FXkyfPOOBs5owBjoId3PxXttnqBTN009QwoiySA2ns4jZ lNv2UOxRJ2sGlZBdlbBvhTWfOnBX57RVNb0jXtNhmSBh8uZvvmYPUbmGm6sz0jRuAQNYUqygubF 4WxWWr0QKYreLMA== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Use the newly defined common and generic PCC shared memory region related macros in this driver to replace the locally defined ones. Cc: Jean Delvare Cc: Guenter Roeck Signed-off-by: Sudeep Holla --- drivers/hwmon/xgene-hwmon.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/hwmon/xgene-hwmon.c b/drivers/hwmon/xgene-hwmon.c index 78d9f52e2a71..1ccdd61b6d13 100644 --- a/drivers/hwmon/xgene-hwmon.c +++ b/drivers/hwmon/xgene-hwmon.c @@ -57,12 +57,6 @@ (MSG_TYPE_SET(MSG_TYPE_PWRMGMT) | \ MSG_SUBTYPE_SET(hndl) | TPC_CMD_SET(cmd) | type) -/* PCC defines */ -#define PCC_SIGNATURE_MASK 0x50424300 -#define PCCC_GENERATE_DB_INT BIT(15) -#define PCCS_CMD_COMPLETE BIT(0) -#define PCCS_SCI_DOORBEL BIT(1) -#define PCCS_PLATFORM_NOTIFICATION BIT(3) /* * Arbitrary retries in case the remote processor is slow to respond * to PCC commands @@ -142,15 +136,15 @@ static int xgene_hwmon_pcc_rd(struct xgene_hwmon_dev *ctx, u32 *msg) /* Write signature for subspace */ WRITE_ONCE(generic_comm_base->signature, - cpu_to_le32(PCC_SIGNATURE_MASK | ctx->mbox_idx)); + cpu_to_le32(PCC_SIGNATURE | ctx->mbox_idx)); /* Write to the shared command region */ WRITE_ONCE(generic_comm_base->command, - cpu_to_le16(MSG_TYPE(msg[0]) | PCCC_GENERATE_DB_INT)); + cpu_to_le16(MSG_TYPE(msg[0]) | PCC_CMD_GENERATE_DB_INTR)); /* Flip CMD COMPLETE bit */ val = le16_to_cpu(READ_ONCE(generic_comm_base->status)); - val &= ~PCCS_CMD_COMPLETE; + val &= ~PCC_STATUS_CMD_COMPLETE; WRITE_ONCE(generic_comm_base->status, cpu_to_le16(val)); /* Copy the message to the PCC comm space */ @@ -544,7 +538,7 @@ static void xgene_hwmon_pcc_rx_cb(struct mbox_client *cl, void *msg) msg = generic_comm_base + 1; /* Check if platform sends interrupt */ if (!xgene_word_tst_and_clr(&generic_comm_base->status, - PCCS_SCI_DOORBEL)) + PCC_STATUS_SCI_DOORBELL)) return; /* @@ -566,7 +560,7 @@ static void xgene_hwmon_pcc_rx_cb(struct mbox_client *cl, void *msg) TPC_CMD(((u32 *)msg)[0]) == TPC_ALARM))) { /* Check if platform completes command */ if (xgene_word_tst_and_clr(&generic_comm_base->status, - PCCS_CMD_COMPLETE)) { + PCC_STATUS_CMD_COMPLETE)) { ctx->sync_msg.msg = ((u32 *)msg)[0]; ctx->sync_msg.param1 = ((u32 *)msg)[1]; ctx->sync_msg.param2 = ((u32 *)msg)[2];