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 3/9] i2c: designware: Convert shared_with_punit boolean as semaphore type
Date: Tue, 6 Feb 2024 16:51:52 +0200 [thread overview]
Message-ID: <20240206145158.227254-4-jarkko.nikula@linux.intel.com> (raw)
In-Reply-To: <20240206145158.227254-1-jarkko.nikula@linux.intel.com>
Remove the shared_with_punit member variable from the struct dw_i2c_dev
and make it one semaphore type. Idea is to make code more uniform when
there is need to differentiate between bus semaphores.
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
---
drivers/i2c/busses/i2c-designware-baytrail.c | 2 +-
drivers/i2c/busses/i2c-designware-core.h | 3 +--
drivers/i2c/busses/i2c-designware-platdrv.c | 8 ++++----
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-baytrail.c b/drivers/i2c/busses/i2c-designware-baytrail.c
index 45774aa47c28..159db4802cdf 100644
--- a/drivers/i2c/busses/i2c-designware-baytrail.c
+++ b/drivers/i2c/busses/i2c-designware-baytrail.c
@@ -38,7 +38,7 @@ int i2c_dw_baytrail_probe_lock_support(struct dw_i2c_dev *dev)
dev_info(dev->dev, "I2C bus managed by PUNIT\n");
dev->acquire_lock = iosf_mbi_block_punit_i2c_access;
dev->release_lock = iosf_mbi_unblock_punit_i2c_access;
- dev->shared_with_punit = true;
+ dev->flags |= SEMAPHORE_INTEL_PUNIT;
return 0;
}
diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
index bac0aec3cb15..30b29d6e58ce 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -235,7 +235,6 @@ struct reset_control;
* @release_lock: function to release a hardware lock on the bus
* @semaphore_idx: Index of table with semaphore type attached to the bus. It's
* -1 if there is no semaphore.
- * @shared_with_punit: true if this bus is shared with the SoCs PUNIT
* @disable: function to disable the controller
* @init: function to initialize the I2C hardware
* @set_sda_hold_time: callback to retrieve IP specific SDA hold timing
@@ -292,7 +291,6 @@ struct dw_i2c_dev {
int (*acquire_lock)(void);
void (*release_lock)(void);
int semaphore_idx;
- bool shared_with_punit;
void (*disable)(struct dw_i2c_dev *dev);
int (*init)(struct dw_i2c_dev *dev);
int (*set_sda_hold_time)(struct dw_i2c_dev *dev);
@@ -304,6 +302,7 @@ struct dw_i2c_dev {
#define ACCESS_NO_IRQ_SUSPEND BIT(1)
#define SEMAPHORE_AMD_PSP (1 << 4)
+#define SEMAPHORE_INTEL_PUNIT (2 << 4)
#define SEMAPHORE_MASK GENMASK(7, 4)
#define MODEL_MSCC_OCELOT (1 << 8)
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index efe9b8e0b7a2..c07385c20cee 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -181,7 +181,7 @@ static void dw_i2c_plat_pm_cleanup(struct dw_i2c_dev *dev)
{
pm_runtime_disable(dev->dev);
- if (dev->shared_with_punit)
+ if ((dev->flags & SEMAPHORE_MASK) == SEMAPHORE_INTEL_PUNIT)
pm_runtime_put_noidle(dev->dev);
}
@@ -381,7 +381,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
pm_runtime_use_autosuspend(&pdev->dev);
pm_runtime_set_active(&pdev->dev);
- if (dev->shared_with_punit)
+ if ((dev->flags & SEMAPHORE_MASK) == SEMAPHORE_INTEL_PUNIT)
pm_runtime_get_noresume(&pdev->dev);
pm_runtime_enable(&pdev->dev);
@@ -433,7 +433,7 @@ static int dw_i2c_plat_runtime_suspend(struct device *dev)
{
struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
- if (i_dev->shared_with_punit)
+ if ((i_dev->flags & SEMAPHORE_MASK) == SEMAPHORE_INTEL_PUNIT)
return 0;
i_dev->disable(i_dev);
@@ -455,7 +455,7 @@ static int dw_i2c_plat_runtime_resume(struct device *dev)
{
struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
- if (!i_dev->shared_with_punit)
+ if ((i_dev->flags & SEMAPHORE_MASK) != SEMAPHORE_INTEL_PUNIT)
i2c_dw_prepare_clk(i_dev, true);
i_dev->init(i_dev);
--
2.43.0
next prev 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 ` [PATCH v2 2/9] i2c: designware: Convert arbitration semaphore flag as semaphore type Jarkko Nikula
2024-02-06 14:51 ` Jarkko Nikula [this message]
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-4-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