[PATCH v2 2/9] i2c: designware: Convert arbitration semaphore flag as semaphore type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux