public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Jarkko Nikula <jarkko.nikula@linux.intel.com>
To: linux-i2c@vger.kernel.org
Cc: Andi Shyti <andi.shyti@kernel.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Jan Dabros <jsd@semihalf.com>,
	Jiawen Wu <jiawenwu@trustnetic.com>,
	Sanket Goswami <Sanket.Goswami@amd.com>,
	Basavaraj Natikar <Basavaraj.Natikar@amd.com>,
	michael.j.ruhl@intel.com, Hans de Goede <hdegoede@redhat.com>,
	Jarkko Nikula <jarkko.nikula@linux.intel.com>
Subject: [PATCH v2 2/9] i2c: designware: Convert arbitration semaphore flag as semaphore type
Date: Tue,  6 Feb 2024 16:51:51 +0200	[thread overview]
Message-ID: <20240206145158.227254-3-jarkko.nikula@linux.intel.com> (raw)
In-Reply-To: <20240206145158.227254-1-jarkko.nikula@linux.intel.com>

Make AMD PSP I2C bus arbitration semaphore flag as a type and add a
related flag bit mask. Only one bus semaphore implementation can be
active at a time so no need to reserve one flag bit for each of them.

Chosen mask size of 4-bits is large considering currently there is only
two semaphore implementations but there is no lack of free flag bits
either.

Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
---
 drivers/i2c/busses/i2c-designware-amdpsp.c  | 2 +-
 drivers/i2c/busses/i2c-designware-core.h    | 4 +++-
 drivers/i2c/busses/i2c-designware-platdrv.c | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-amdpsp.c b/drivers/i2c/busses/i2c-designware-amdpsp.c
index 63454b06e5da..5d788281fe7a 100644
--- a/drivers/i2c/busses/i2c-designware-amdpsp.c
+++ b/drivers/i2c/busses/i2c-designware-amdpsp.c
@@ -284,7 +284,7 @@ int i2c_dw_amdpsp_probe_lock_support(struct dw_i2c_dev *dev)
 	if (!dev)
 		return -ENODEV;
 
-	if (!(dev->flags & ARBITRATION_SEMAPHORE))
+	if ((dev->flags & SEMAPHORE_MASK) != SEMAPHORE_AMD_PSP)
 		return -ENODEV;
 
 	/* Allow to bind only one instance of a driver */
diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
index 4e1f0924f493..bac0aec3cb15 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -302,7 +302,9 @@ struct dw_i2c_dev {
 
 #define ACCESS_INTR_MASK			BIT(0)
 #define ACCESS_NO_IRQ_SUSPEND			BIT(1)
-#define ARBITRATION_SEMAPHORE			BIT(2)
+
+#define SEMAPHORE_AMD_PSP			(1 << 4)
+#define SEMAPHORE_MASK				GENMASK(7, 4)
 
 #define MODEL_MSCC_OCELOT			(1 << 8)
 #define MODEL_BAIKAL_BT1			(2 << 8)
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 855b698e99c0..efe9b8e0b7a2 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -50,7 +50,7 @@ static const struct acpi_device_id dw_i2c_acpi_match[] = {
 	{ "808622C1", ACCESS_NO_IRQ_SUSPEND },
 	{ "AMD0010", ACCESS_INTR_MASK },
 	{ "AMDI0010", ACCESS_INTR_MASK },
-	{ "AMDI0019", ACCESS_INTR_MASK | ARBITRATION_SEMAPHORE },
+	{ "AMDI0019", ACCESS_INTR_MASK | SEMAPHORE_AMD_PSP },
 	{ "AMDI0510", 0 },
 	{ "APMC0D0F", 0 },
 	{ "HISI02A1", 0 },
-- 
2.43.0


  parent reply	other threads:[~2024-02-06 14:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-06 14:51 [PATCH v2 0/9] i2c: designware: Generic polling mode code Jarkko Nikula
2024-02-06 14:51 ` [PATCH v2 1/9] i2c: designware: Add some flexiblity to the model info Jarkko Nikula
2024-02-06 15:30   ` Andy Shevchenko
2024-02-09 14:14     ` Jarkko Nikula
2024-02-09 14:25       ` Andy Shevchenko
2024-02-06 14:51 ` Jarkko Nikula [this message]
2024-02-06 14:51 ` [PATCH v2 3/9] i2c: designware: Convert shared_with_punit boolean as semaphore type Jarkko Nikula
2024-02-06 14:51 ` [PATCH v2 4/9] i2c: designware: Uniform initialization flow for polling mode Jarkko Nikula
2024-02-06 15:13   ` Andy Shevchenko
2024-02-06 14:51 ` [PATCH v2 5/9] i2c: designware: Do not enable interrupts shortly in " Jarkko Nikula
2024-02-06 14:51 ` [PATCH v2 6/9] i2c: designware: Use accessors to DW_IC_INTR_MASK register Jarkko Nikula
2024-02-06 14:51 ` [PATCH v2 7/9] i2c: designware: Move interrupt handling functions before i2c_dw_xfer() Jarkko Nikula
2024-02-06 15:18   ` Andy Shevchenko
2024-02-06 14:51 ` [PATCH v2 8/9] i2c: designware: Fix RX FIFO depth define on Wangxun 10Gb NIC Jarkko Nikula
2024-02-06 14:51 ` [PATCH v2 9/9] i2c: designware: Implement generic polling mode code for " Jarkko Nikula
2024-02-06 15:28   ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240206145158.227254-3-jarkko.nikula@linux.intel.com \
    --to=jarkko.nikula@linux.intel.com \
    --cc=Basavaraj.Natikar@amd.com \
    --cc=Sanket.Goswami@amd.com \
    --cc=andi.shyti@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=hdegoede@redhat.com \
    --cc=jiawenwu@trustnetic.com \
    --cc=jsd@semihalf.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=michael.j.ruhl@intel.com \
    --cc=mika.westerberg@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox